@openfin/cloud-interop-core-api 0.0.1-alpha.94bf3ec → 0.0.1-alpha.9655dc9

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.
@@ -1,5 +1,6 @@
1
+ import { EndReportIntentsEvent, Intent, IntentDetailsEvent, IntentResultEvent, InvokeIntentEvent, ReportIntentsEvent } from '@openfin-direct/shared-utils';
1
2
  import mqtt from 'mqtt';
2
- import { CloudInteropSettings, ConnectParameters as ConnectParameters, ContextEvent } from './interfaces';
3
+ import { CloudInteropSettings, ConnectParameters, ContextEvent } from './interfaces';
3
4
  type CreateSessionResponse = {
4
5
  sessionId: string;
5
6
  sessionRootTopic: string;
@@ -17,6 +18,11 @@ type EventMap = {
17
18
  reconnecting: (attemptNo: number) => void;
18
19
  error: (error: Error) => void;
19
20
  'session-expired': () => void;
21
+ 'report-intents': (event: ReportIntentsEvent) => void;
22
+ 'end-report-intents': (event: EndReportIntentsEvent) => void;
23
+ 'intent-details': (event: IntentDetailsEvent) => void;
24
+ 'invoke-intent': (event: InvokeIntentEvent) => void;
25
+ 'intent-result': (event: IntentResultEvent) => void;
20
26
  };
21
27
  /**
22
28
  * Represents a single connection to a Cloud Interop service
@@ -57,6 +63,25 @@ export declare class CloudInteropAPI {
57
63
  * @memberof CloudInteropAPI
58
64
  */
59
65
  setContext(contextGroup: string, context: object): Promise<void>;
66
+ /**
67
+ * Starts an intent discovery operation
68
+ *
69
+ * @return {*} {Promise<void>}
70
+ * @memberof CloudInteropAPI
71
+ * @throws {CloudInteropAPIError} - If an error occurs during intent discovery
72
+ */
73
+ startIntentDiscovery(): Promise<void>;
74
+ /**
75
+ * Ends an intent discovery operation
76
+ *
77
+ * @return {*} {Promise<void>}
78
+ * @memberof CloudInteropAPI
79
+ * @throws {CloudInteropAPIError} - If an error occurs during stopping intent discovery
80
+ */
81
+ endIntentDiscovery(): Promise<void>;
82
+ raiseIntent(intent: Intent, targetSessionId: string): Promise<void>;
83
+ reportSupportedIntents(discoveryId: string, intents: Intent[]): Promise<void>;
84
+ sendIntentResult(resultEvent: IntentResultEvent): Promise<void>;
60
85
  addEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
61
86
  removeEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
62
87
  }
@@ -100,23 +100,6 @@ export type Source = {
100
100
  */
101
101
  sourceDisplayName: string;
102
102
  };
103
- /**
104
- * Represents the details of an intent found during discovery
105
- */
106
- export type IntentDetail = {
107
- /**
108
- * The location of the intent implementation
109
- */
110
- source: Source;
111
- /**
112
- * The instance id of the intent
113
- */
114
- intentInstanceId: string;
115
- /**
116
- * The name of the intent
117
- */
118
- intentName: string;
119
- };
120
103
  /**
121
104
  * Represents a context received from another cloud interop publisher
122
105
  *
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,128 @@
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/cloud-interop-core-api",
3
- "version": "0.0.1-alpha.94bf3ec",
3
+ "version": "0.0.1-alpha.9655dc9",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "files": [
@@ -8,9 +8,9 @@
8
8
  ],
9
9
  "main": "./dist/index.cjs",
10
10
  "browser": "./dist/index.mjs",
11
- "types": "./dist/index.d.ts",
11
+ "types": "./dist/src/index.d.ts",
12
12
  "scripts": {
13
- "build": "rollup -c",
13
+ "build": "rimraf dist && rollup -c",
14
14
  "build:watch": "rollup -c --watch",
15
15
  "typecheck": "tsc --noEmit",
16
16
  "test": "jest --coverage",
@@ -25,7 +25,7 @@
25
25
  "@rollup/plugin-node-resolve": "^15.2.3",
26
26
  "@rollup/plugin-typescript": "^11.1.6",
27
27
  "@types/jest": "^29.5.14",
28
- "@types/node": "^20.10.0",
28
+ "@types/node": "^22.7.7",
29
29
  "@typescript-eslint/eslint-plugin": "^7.5.0",
30
30
  "@typescript-eslint/parser": "^7.15.0",
31
31
  "eslint": "^8.57.0",
@@ -42,7 +42,7 @@
42
42
  "typescript": "^5.6.3"
43
43
  },
44
44
  "dependencies": {
45
- "axios": "^1.6.2",
45
+ "@openfin-direct/shared-utils": "file:../shared-utils",
46
46
  "mqtt": "^5.3.1"
47
47
  },
48
48
  "eslintConfig": {
File without changes
File without changes