@interopio/browser 3.0.1 → 3.0.3

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/browser.d.ts ADDED
@@ -0,0 +1,1611 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /* eslint-disable @typescript-eslint/no-empty-interface */
4
+ import { UnsubscribeFunction } from "callback-registry";
5
+ import { IOConnectCore } from "@interopio/core";
6
+ import { Glue42 } from "@glue42/desktop";
7
+ import { IOConnectWorkspaces } from "@interopio/workspaces-api";
8
+ import { IOConnectSearch } from "@interopio/search-api";
9
+
10
+ /**
11
+ * Factory function that creates a new ioconnect instance.
12
+ * If your application is running in IOConnect Desktop this will return a Glue42.Glue API, which is a super-set of the IOConnectBrowser.API.
13
+ */
14
+ export type IOConnectBrowserFactoryFunction = (config?: IOConnectBrowser.Config) => Promise<IOConnectBrowser.API | Glue42.Glue>;
15
+ declare const IOConnectBrowserFactory: IOConnectBrowserFactoryFunction;
16
+ export default IOConnectBrowserFactory;
17
+
18
+ /**
19
+ * @docname io.Connect Browser
20
+ * @intro
21
+ * **io.Connect Browser** allows web apps to integrate with other apps that are part of the same **io.Connect Browser** project via a set of APIs.
22
+ * **io.Connect Browser** enables you to share data between apps, expose functionality, manage windows and notifications.
23
+ *
24
+ * ## Referencing
25
+ *
26
+ * The [`&commat;interopio/browser`](https://www.npmjs.com/package/&commat;interopio/browser) library is available both as a single JavaScript file, which you can include in your web apps using a `<script>` tag, and as a Node.js module:
27
+ *
28
+ * ```html
29
+ * <script type="text/javascript" src="browser.umd.js"></script>
30
+ * ```
31
+ *
32
+ * Or:
33
+ *
34
+ * ``` javascript
35
+ * import IOBrowser from "&commat;interopio/browser";
36
+ * ```
37
+ *
38
+ * When deploying your app in production, it's recommended to always reference a specific minified version:
39
+ *
40
+ * ```html
41
+ * <script type="text/javascript" src="browser.umd.min.js"></script>
42
+ * ```
43
+ *
44
+ * ## Initialization
45
+ *
46
+ * The [`&commat;interopio/browser`](https://www.npmjs.com/package/&commat;interopio/browser) library attaches a factory function to the global `window` object at runtime - `IOBrowser()`.
47
+ * It can be invoked with an optional configuration object to initialize the library and connect to the **io.Connect Browser** environment. The factory function resolves with the `io` API object:
48
+ *
49
+ * ```javascript
50
+ * const initializeIOConnect = async () => {
51
+ *
52
+ * // Initializing the Workspaces library.
53
+ * const initOptions = {
54
+ * libraries: [IOWorkspaces]
55
+ * };
56
+ *
57
+ * // Use the object returned from the factory function
58
+ * // to access the IOConnect Browser APIs.
59
+ * const io = await IOBrowser(initOptions);
60
+ *
61
+ * // Here the library is initialized and you can access all io.Connect Browser APIs.
62
+ * };
63
+ *
64
+ * initializeIOConnect().catch(console.error);
65
+ * ```
66
+ */
67
+ export namespace IOConnectBrowser {
68
+
69
+ export import Interop = IOConnectCore.Interop;
70
+ export import Contexts = IOConnectCore.Contexts;
71
+ export import Logger = IOConnectCore.Logger;
72
+
73
+ export interface Config {
74
+ /**
75
+ * Configure the system logger. Used mostly for during development.
76
+ */
77
+ systemLogger?: SystemLogger;
78
+
79
+ /**
80
+ * Connect with GW in memory.
81
+ * Used for testing in node environment, where the GW isn't started by &commat;glue42/worker-web and an inproc GW is used instead.
82
+ * @ignore
83
+ */
84
+ inproc?: IOConnectCore.InprocGWSettings;
85
+
86
+ /**
87
+ * Configure the system logger. Used mostly for during development.
88
+ */
89
+ notifications?: Notifications.Settings;
90
+
91
+ /** Enable, disable and configure the Contexts API. Enabled by default */
92
+ contexts?: IOConnectCore.ContextsConfig;
93
+
94
+ /**
95
+ * Configures whether the library will share the initialized API object upon request via a custom web event.
96
+ * @default true
97
+ */
98
+ exposeAPI?: boolean;
99
+
100
+ /**
101
+ * A list of io.Connect libraries which will be initiated internally and provide access to specific functionalities
102
+ */
103
+ libraries?: Array<(io: IOConnectBrowser.API, config?: IOConnectBrowser.Config | Glue42.Config) => Promise<void>>;
104
+
105
+ /* Enable and configure Intents Resolver UI */
106
+ intents?: IOConnectBrowser.Intents.Config;
107
+ }
108
+
109
+ export interface SystemLogger {
110
+ level?: IOConnectCore.Logger.LogLevel;
111
+ callback?: (logInfo: any) => void;
112
+ }
113
+
114
+ export interface API extends IOConnectCore.API {
115
+ windows: IOConnectBrowser.Windows.API;
116
+ layouts: IOConnectBrowser.Layouts.API;
117
+ notifications: IOConnectBrowser.Notifications.API;
118
+ channels: IOConnectBrowser.Channels.API;
119
+ appManager: IOConnectBrowser.AppManager.API;
120
+ intents: IOConnectBrowser.Intents.API;
121
+ themes?: IOConnectBrowser.Themes.API;
122
+ workspaces?: IOConnectWorkspaces.API;
123
+ search?: IOConnectSearch.API;
124
+ webPlatform?: IOConnectBrowser.WebPlatform.API;
125
+ }
126
+
127
+ /**
128
+ * @intro
129
+ * Using the Window Management API, your application can easily open and manipulate browser windows.
130
+ * This allows you to transform your traditional single-window web app into a multi-window native-like web application.
131
+ * The Window Management API enables applications to:
132
+ *
133
+ * - open multiple windows;
134
+ * - manipulate the position and size of opened windows;
135
+ * - pass context data upon opening new windows;
136
+ * - listen for and handle events related to opening and closing windows;
137
+ *
138
+ * The Window Management API is accessible through the `io.windows` object.
139
+ */
140
+ export namespace Windows {
141
+ export interface API {
142
+ list(): WebWindow[];
143
+
144
+ /** Returns the current window. */
145
+ my(): WebWindow;
146
+
147
+ /**
148
+ * Finds a window by ID.
149
+ * @param id Window ID.
150
+ */
151
+ findById(id: string): WebWindow | undefined;
152
+
153
+ /**
154
+ * Opens a new IO Connect Browser Window.
155
+ * @param name The name for the window
156
+ * @param url The window URL.
157
+ * @param options Options for creating a window.
158
+ */
159
+ open(name: string, url: string, options?: Settings): Promise<WebWindow>;
160
+
161
+ /**
162
+ * Notifies when a new window is opened.
163
+ * @param callback Callback function to handle the event. Receives the added window as a parameter. Returns an unsubscribe function.
164
+ */
165
+ onWindowAdded(callback: (window: WebWindow) => void): UnsubscribeFunction;
166
+
167
+ /**
168
+ * Notifies when a window is closed. For backwards compatibility, you can also use `windowRemoved`.
169
+ * @param callback Callback function to handle the event. Receives the removed window as a parameter. Returns an unsubscribe function.
170
+ */
171
+ onWindowRemoved(callback: (window: WebWindow) => void): UnsubscribeFunction;
172
+
173
+ /**
174
+ * Notifies when a window receives focus.
175
+ * @param callback Callback function to handle the event. Receives the window instance as a parameter. Returns an unsubscribe function.
176
+ */
177
+ onWindowGotFocus(callback: (window: WebWindow) => void): UnsubscribeFunction;
178
+
179
+ /**
180
+ * Notifies when a window loses focus.
181
+ * @param callback Callback function to handle the event. Receives the window instance as a parameter. Returns an unsubscribe function.
182
+ */
183
+ onWindowLostFocus(callback: (window: WebWindow) => void): UnsubscribeFunction;
184
+ }
185
+
186
+ export interface WebWindow {
187
+ id: string;
188
+
189
+ name: string;
190
+
191
+ isFocused: boolean;
192
+
193
+ /**
194
+ * Gets the current URL of the window.
195
+ */
196
+ getURL(): Promise<string>;
197
+
198
+ /**
199
+ * Sets new location and size for the window. The accepted settings are absolute.
200
+ * @param dimension The object containing the desired absolute size and location.
201
+ */
202
+ moveResize(dimension: Partial<Bounds>): Promise<WebWindow>;
203
+
204
+ /**
205
+ * Sets a new size of the window. The accepted settings are relative.
206
+ * @param width Relative width of the window.
207
+ * @param height Relative height of the window.
208
+ */
209
+ resizeTo(width?: number, height?: number): Promise<WebWindow>;
210
+
211
+ /**
212
+ * Sets a new location of the window. The accepted settings are relative.
213
+ * @param top Relative distance top coordinates.
214
+ * @param left Relative distance left coordinates.
215
+ */
216
+ moveTo(top?: number, left?: number): Promise<WebWindow>;
217
+
218
+ /**
219
+ * Attempts to activate and bring to foreground the window. It is possible to fail due to client browser settings.
220
+ */
221
+ focus(): Promise<WebWindow>;
222
+
223
+ /**
224
+ * Closes the window
225
+ * @default 0
226
+ */
227
+ close(): Promise<WebWindow>;
228
+
229
+ /**
230
+ * Returns the title of the window.
231
+ * @default 0
232
+ */
233
+ getTitle(): Promise<string>;
234
+
235
+ /**
236
+ * Sets a new title for the window
237
+ * @param title The new title value.
238
+ */
239
+ setTitle(title: string): Promise<WebWindow>;
240
+
241
+ /**
242
+ * Returns the current location and size of the window.
243
+ */
244
+ getBounds(): Promise<Bounds>;
245
+
246
+ /**
247
+ * Gets the current context object of the window.
248
+ */
249
+ getContext(): Promise<any>;
250
+
251
+ /**
252
+ * Updates the context object of the window
253
+ * @param context The new context object for the window.
254
+ */
255
+ updateContext(context: any): Promise<WebWindow>;
256
+
257
+ /**
258
+ * Sets new context for the window.
259
+ * @param context The new context object for the window.
260
+ */
261
+ setContext(context: any): Promise<WebWindow>;
262
+
263
+ /**
264
+ * Notifies when a change to the window's context has been made.
265
+ * @param callback The function which will be invoked when a change to the window's context happens. The function will be called with the new context and window as arguments.
266
+ */
267
+ onContextUpdated(callback: (context: any, window: WebWindow) => void): UnsubscribeFunction;
268
+
269
+ /**
270
+ * Notifies when the window focus is changed.
271
+ * @param callback Callback function to handle the event. Returns an unsubscribe function.
272
+ */
273
+ onFocusChanged(callback: (window: WebWindow) => void): UnsubscribeFunction;
274
+ }
275
+ export interface Settings {
276
+
277
+ /**
278
+ * Distance of the top left window corner from the top edge of the screen.
279
+ * @default 0
280
+ */
281
+ top?: number;
282
+
283
+ /**
284
+ * Distance of the top left window corner from the left edge of the screen.
285
+ * @default 0
286
+ */
287
+ left?: number;
288
+
289
+ /**
290
+ * Window width.
291
+ * @default 400
292
+ */
293
+ width?: number;
294
+
295
+ /**
296
+ * Window height.
297
+ * @default 400
298
+ */
299
+ height?: number;
300
+
301
+ /**
302
+ * The initial window context. Accessible from {@link WebWindow#getContext}
303
+ */
304
+ context?: any;
305
+
306
+ /**
307
+ * The ID of the window that will be used to relatively position the new window.
308
+ * Can be combined with `relativeDirection`.
309
+ */
310
+ relativeTo?: string;
311
+
312
+ /**
313
+ * Direction (`"bottom"`, `"top"`, `"left"`, `"right"`) of positioning the window relatively to the `relativeTo` window. Considered only if `relativeTo` is supplied.
314
+ * @default "right"
315
+ */
316
+ relativeDirection?: RelativeDirection;
317
+ }
318
+
319
+ export type RelativeDirection = "top" | "left" | "right" | "bottom";
320
+
321
+ export interface Bounds {
322
+ top: number;
323
+ left: number;
324
+ width: number;
325
+ height: number;
326
+ }
327
+ }
328
+
329
+ /**
330
+ * @intro
331
+ * The Layouts library has the following capabilities:
332
+ *
333
+ * - importing, exporting, removing and getting Layouts;
334
+ * - saving and restoring Layouts;
335
+ * - events related to adding, removing, changing or saving Layouts;
336
+ * - requesting browser permission for the Multi-Screen Window Placement API;
337
+ *
338
+ * The Layouts API is accessible through the `io.layouts` object.
339
+ */
340
+ namespace Layouts {
341
+
342
+ /**
343
+ *
344
+ * Type of the Layout. Supported Layouts are `"Global"` and `"Workspace"`.
345
+ *
346
+ */
347
+ export type LayoutType = "Global" | "Activity" | "ApplicationDefault" | "Swimlane" | "Workspace";
348
+
349
+ /**
350
+ * Controls the import behavior. If `"replace"` (default), all existing Layouts will be removed.
351
+ * If `"merge"`, the Layouts will be added to the existing ones.
352
+ */
353
+ export type ImportMode = "replace" | "merge";
354
+
355
+ /**
356
+ * Layouts API.
357
+ */
358
+ export interface API {
359
+
360
+ /**
361
+ * Fetches a saved Layout if a Layout with the provided name and type exists.
362
+ * @param type Type of the Layout to fetch.
363
+ * @param name Name of the Layout to fetch.
364
+ */
365
+ get(name: string, type: LayoutType): Promise<Layout | undefined>;
366
+
367
+ /**
368
+ * Returns a lightweight description of all Layouts of the provided type, without the extensive objects describing the Layout components.
369
+ * @param type Type of the Layouts to fetch.
370
+ */
371
+ getAll(type: LayoutType): Promise<LayoutSummary[]>;
372
+
373
+ /**
374
+ * Returns a collection of all available `Layout` objects of the provided type.
375
+ * @param type Type of the Layouts to export.
376
+ */
377
+ export(layoutType: LayoutType): Promise<Layout[]>;
378
+
379
+ /**
380
+ * Imports a collection of `Layout` objects.
381
+ * @param layouts An array of `Layout` objects to be imported.
382
+ * @param mode If `"replace"` (default), all existing Layouts will be removed. If `"merge"`, the Layouts will be added to the existing ones.
383
+ */
384
+ import(layouts: Layout[], mode?: ImportMode): Promise<void>;
385
+
386
+ /**
387
+ * Saves a new Layout.
388
+ * @param layout Options for saving a Layout.
389
+ */
390
+ save(layout: NewLayoutOptions): Promise<Layout>;
391
+
392
+ /**
393
+ * Restores a Layout.
394
+ * @param options Options for restoring a Layout.
395
+ */
396
+ restore(options: RestoreOptions): Promise<void>;
397
+
398
+ /**
399
+ * Removes a Layout.
400
+ * @param type Type of the Layout to remove.
401
+ * @param name Name of the Layout to remove.
402
+ */
403
+ remove(type: LayoutType, name: string): Promise<void>;
404
+
405
+ /**
406
+ * Notifies when a new Layout is added.
407
+ * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
408
+ */
409
+ onAdded(callback: (layout: Layout) => void): () => void;
410
+
411
+ /**
412
+ * Notifies when a Layout is modified.
413
+ * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
414
+ */
415
+ onChanged(callback: (layout: Layout) => void): () => void;
416
+
417
+ /**
418
+ * Notifies when a Layout is removed.
419
+ * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
420
+ */
421
+ onRemoved(callback: (layout: Layout) => void): () => void;
422
+
423
+ /**
424
+ * Subscribes for Layout save requests.
425
+ * @param callback The callback passed as an argument will be invoked when a Layout save operation is requested.
426
+ * You have the option to save data (context) which will be restored when the Layout is restored.
427
+ * Returns an unsubscribe function.
428
+ */
429
+ onSaveRequested(callback: (info?: SaveRequestContext) => SaveRequestResponse): () => void;
430
+
431
+ /**
432
+ * Retrieves the browser Multi-Screen Window Placement permission state for the **io.Connect Browser** environment.
433
+ */
434
+ getMultiScreenPermissionState(): Promise<{ state: "prompt" | "granted" | "denied" }>;
435
+
436
+ /**
437
+ * Opens the browser permission prompt requesting Multi-Screen Window Placement permission from the user for the **io.Connect Browser** environment.
438
+ * This can only be requested from the Main app (Web Platform) due to the transient activation restrictions of the browsers.
439
+ */
440
+ requestMultiScreenPermission(): Promise<{ permissionGranted: boolean }>;
441
+
442
+ /**
443
+ * Checks whether Global Layouts are activated in the **io.Connect Browser** environment.
444
+ */
445
+ getGlobalTypeState(): Promise<{ activated: boolean }>;
446
+
447
+ /**
448
+ * Retrieves the default Global Layout, if any.
449
+ */
450
+ getDefaultGlobal(): Promise<Layout | undefined>;
451
+
452
+ /**
453
+ * Sets a new default Global Layout.
454
+ * @param name Name of the Global Layout to set as default.
455
+ */
456
+ setDefaultGlobal(name: string): Promise<void>;
457
+
458
+ /**
459
+ * Removes the default Global Layout.
460
+ */
461
+ clearDefaultGlobal(): Promise<void>;
462
+ }
463
+
464
+ /**
465
+ * Describes a Layout and its components.
466
+ */
467
+ export interface Layout {
468
+ /** Name of the Layout. The name is unique per Layout type. */
469
+ name: string;
470
+
471
+ /** Type of the Layout. */
472
+ type: LayoutType;
473
+
474
+ /** Array of component objects describing the apps and Workspaces saved in the Layout. */
475
+ components: Array<WindowComponent | WorkspaceFrameComponent | IOConnectWorkspaces.WorkspaceComponent>;
476
+
477
+ /** Context object passed when the Layout was saved. */
478
+ context?: any;
479
+
480
+ /** Metadata passed when the Layout was saved. */
481
+ metadata?: any;
482
+
483
+ /** Version of the Layout. */
484
+ version?: number;
485
+ }
486
+
487
+ /**
488
+ * @ignore
489
+ */
490
+ export type ComponentType = "application" | "activity";
491
+
492
+ /**
493
+ * @ignore
494
+ */
495
+ export interface WorkspaceFrameComponent {
496
+ type: "workspaceFrame";
497
+
498
+ /** The name of the workspace application. This is supported only in Enterprise */
499
+ application: string;
500
+
501
+ /** Type of the component - can be application or activity. */
502
+ componentType?: ComponentType;
503
+
504
+ /** Object describing the application bounds, name, context, etc. */
505
+ state: WorkspaceFrameComponentState;
506
+ }
507
+
508
+ /**
509
+ * @ignore
510
+ */
511
+ export interface WorkspaceFrameComponentState {
512
+ bounds: IOConnectBrowser.Windows.Bounds;
513
+ instanceId: string;
514
+ selectedWorkspace: number;
515
+ workspaces: IOConnectWorkspaces.WorkspaceLayoutComponentState[];
516
+ windowState?: string;
517
+ restoreState?: string;
518
+ context?: any;
519
+ }
520
+
521
+ /**
522
+ * @ignore
523
+ */
524
+ export interface WindowComponent {
525
+ type: "window";
526
+
527
+ /** Type of the component - can be application or activity. */
528
+ componentType?: ComponentType;
529
+
530
+ /** The name of the originating application for the instance or "no-app-window" if it was not started as an application instance */
531
+ application: string;
532
+
533
+ /** Object describing the application bounds, name, context, etc. */
534
+ state: WindowComponentState;
535
+ }
536
+
537
+ /**
538
+ * @ignore
539
+ */
540
+ export interface WindowComponentState {
541
+ context?: any;
542
+ bounds: IOConnectBrowser.Windows.Bounds;
543
+ createArgs: WindowComponentCreateArgs;
544
+ windowState?: string,
545
+ restoreState?: string,
546
+ restoreSettings?: {
547
+ groupId?: string,
548
+ groupZOrder?: number
549
+ },
550
+ instanceId: string,
551
+ isSticky?: boolean,
552
+ isCollapsed?: boolean
553
+ }
554
+
555
+ /**
556
+ * @ignore
557
+ */
558
+ export interface WindowComponentCreateArgs {
559
+ name?: string;
560
+ url?: string;
561
+ context?: any;
562
+ }
563
+
564
+ /**
565
+ * A lightweight description of a Layout, without the extensive objects describing its components.
566
+ */
567
+ export interface LayoutSummary {
568
+ /** Name of the Layout. The name is unique per Layout type. */
569
+ name: string;
570
+
571
+ /** Type of the Layout. */
572
+ type: LayoutType;
573
+
574
+ /** Context object passed when the Layout was saved. */
575
+ context?: any;
576
+
577
+ /** Metadata passed when the Layout was saved. */
578
+ metadata?: any;
579
+ }
580
+
581
+ /**
582
+ * Options for saving a Layout.
583
+ */
584
+ export interface NewLayoutOptions {
585
+ /** Name for the Layout. */
586
+ name: string;
587
+
588
+ /**
589
+ * Context to be saved with the Layout. Used for transferring data to the apps when restoring a Layout.
590
+ */
591
+ context?: any;
592
+
593
+ /**
594
+ * Metadata to be saved with the Layout.
595
+ */
596
+ metadata?: any;
597
+
598
+ /**
599
+ * Window or app instance IDs of the instances to be saved in the Layout.
600
+ */
601
+ instances?: string[];
602
+
603
+ /**
604
+ * Window or app instance IDs of the instances to be ignored when saving the Layout.
605
+ */
606
+ ignoreInstances?: string[];
607
+ }
608
+
609
+ /**
610
+ * Options for restoring a Layout.
611
+ */
612
+ export interface RestoreOptions {
613
+
614
+ /**
615
+ * Name of the Layout to restore.
616
+ */
617
+ name: string;
618
+
619
+ /**
620
+ * Context object that will be passed to the restored apps. It will be merged with the saved context object.
621
+ */
622
+ context?: object;
623
+
624
+ /**
625
+ * If `true`, will close all visible running instances before restoring the Layout.
626
+ * The only exception is the Main app (Web Platform) - it will never be closed when restoring a Layout.
627
+ * @default true
628
+ */
629
+ closeRunningInstances?: boolean;
630
+
631
+ /**
632
+ * If `true`, will close the current app before restoring a Layout. If `closeRunningInstances` is set to `false`, this will default to `false` too.
633
+ * @default true
634
+ */
635
+ closeMe?: boolean;
636
+
637
+ /**
638
+ * Timeout in milliseconds for restoring the Layout. If the time limit is hit, all apps opened up to this point will be closed and an error will be thrown.
639
+ * @default 60000
640
+ */
641
+ timeout?: number;
642
+ }
643
+
644
+ /**
645
+ * Object returned by the handler for a save Layout request.
646
+ */
647
+ export interface SaveRequestResponse {
648
+ /** Context to be saved for the specific app in the Layout. */
649
+ windowContext: object;
650
+ }
651
+
652
+ /**
653
+ * Object passed as an argument to the handler for a save Layout request.
654
+ */
655
+ export interface SaveRequestContext {
656
+ /** Context for the Layout. */
657
+ context?: unknown;
658
+ /** Name of the Layout. */
659
+ layoutName: string;
660
+ /** Type of the Layout. */
661
+ layoutType: LayoutType;
662
+ }
663
+ }
664
+
665
+ /**
666
+ * @intro
667
+ * The Notifications API provides a way to display native notifications with actions and to handle notification and action clicks.
668
+ * **io.Connect Browser** supports all available `Notification` settings as defined in the [DOM Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API).
669
+ *
670
+ * The **io.Connect Browser** Notifications API extends the DOM Notifications API with the option to handle notification and action clicks using Interop methods.
671
+ *
672
+ * The Notifications API is accessible through the `io.notifications` object.
673
+ */
674
+ export namespace Notifications {
675
+ export interface API {
676
+ /**
677
+ * Raises a new notification
678
+ * @param notification notification options
679
+ */
680
+ raise(notification: RaiseOptions): Promise<Notification>;
681
+
682
+ /**
683
+ * **io.Connect Browser** only. Retrieves the state of the native browser notification permission for the platform.
684
+ */
685
+ getPermission?(): Promise<"default" | "granted" | "denied">;
686
+
687
+ /**
688
+ * **io.Connect Browser** only. Triggers the native browser permission dialog. Must only be called from within a platform.
689
+ */
690
+ requestPermission?(): Promise<boolean>;
691
+
692
+ /** Returns a list of all known notifications. */
693
+ list(): Promise<NotificationData[]>;
694
+
695
+ /**
696
+ * Notifies the user of any new raised notifications via the Notifications API.
697
+ * @param callback A function which will be called when a new notification is raised.
698
+ */
699
+ onRaised(callback: (notification: NotificationData) => void): UnsubscribeFunction;
700
+
701
+ /**
702
+ * Notifies the user when a notification was removed via the Notifications API.
703
+ * @param callback A function which will be called when a notification is removed.
704
+ */
705
+ onClosed(callback: (notification: { id: string }) => void): UnsubscribeFunction;
706
+
707
+ /**
708
+ * Issues a programmatic click on a notification.
709
+ * @param id The id of the notification to click on.
710
+ * @param actions Optional action value to click on.
711
+ */
712
+ click(id: string, action?: string): Promise<void>;
713
+
714
+ /**
715
+ * Clears a specified notification.
716
+ * @param id The id of the notification to be removed.
717
+ */
718
+ clear(id: string): Promise<void>;
719
+
720
+ /** Removes all known notifications from the system. */
721
+ clearAll(): Promise<void>;
722
+ }
723
+
724
+ export interface NotificationDefinition {
725
+ badge?: string;
726
+ body?: string;
727
+ data?: any;
728
+ dir?: "auto" | "ltr" | "rtl";
729
+ icon?: string;
730
+ image?: string;
731
+ lang?: string;
732
+ renotify?: boolean;
733
+ requireInteraction?: boolean;
734
+ silent?: boolean;
735
+ tag?: string;
736
+ timestamp?: number;
737
+ vibrate?: number[];
738
+ }
739
+
740
+ export interface RaiseOptions extends NotificationDefinition {
741
+ /** The title of the notification */
742
+ title: string;
743
+ /** Set to make the notification click invoke an interop method with specific arguments */
744
+ clickInterop?: InteropActionSettings;
745
+ /** List of action attached to the notification. Those will appear as buttons in the notification UI */
746
+ actions?: NotificationAction[];
747
+ /** **io.Connect Browser** only. If set to true, the platform app will be focused when the user clicks on the notification. Defaults to false. */
748
+ focusPlatformOnDefaultClick?: boolean;
749
+ /** Severity of the alert */
750
+ severity?: "Low" | "Medium" | "High" | "Critical" | "None";
751
+ /** Indicates whether a native toast will be shown or not. Defaults to true */
752
+ showToast?: boolean;
753
+ /** Indicates whether the notification should appear in notification panels. Defaults to true */
754
+ showInPanel?: boolean;
755
+ }
756
+
757
+ export interface NotificationData extends RaiseOptions {
758
+ id: string;
759
+ }
760
+
761
+ export interface Notification extends NotificationData {
762
+ onclick: () => any;
763
+ onshow: () => any;
764
+ }
765
+
766
+ export interface NotificationAction {
767
+ action: string;
768
+ title: string;
769
+ icon?: string;
770
+ /** set to make the action invoke an interop method with specific arguments */
771
+ interop?: InteropActionSettings;
772
+ }
773
+
774
+ export interface InteropActionSettings {
775
+ method: string;
776
+ arguments?: any;
777
+ target?: "all" | "best";
778
+ }
779
+
780
+ export type NotificationClickHandler = (io: IOConnectBrowser.API, notificationDefinition: NotificationDefinition) => void;
781
+
782
+ export interface ActionClickHandler {
783
+ action: string;
784
+ handler: NotificationClickHandler;
785
+ }
786
+
787
+ export interface Settings {
788
+ defaultClick: NotificationClickHandler;
789
+ actionClicks: ActionClickHandler[];
790
+ }
791
+ }
792
+
793
+ /**
794
+ * @intro
795
+ * Channels are globally accessed named contexts that allow users to dynamically group apps, instructing them to work over the same shared data object.
796
+ * The Channels API enables you to:
797
+ *
798
+ * - discover Channels - get the names and contexts of all Channels;
799
+ * - navigate through Channels - get the current Channel, join and leave Channels, subscribe for the event which fires when the current Channel has changed;
800
+ * - publish and subscribe - publish data to other apps on the same Channel and subscribe for Channel updates to react to data published by other apps;
801
+ *
802
+ * The Channels API is accessible through the `io.channels` object.
803
+ */
804
+ namespace Channels {
805
+ /**
806
+ * Channels API.
807
+ */
808
+ export interface API {
809
+ /**
810
+ * Tracks the data in the current channel. Persisted after a channel change.
811
+ * The callback isn't called when you publish the data.
812
+ * @param callback Callback function to handle the received data.
813
+ * @returns Unsubscribe function.
814
+ */
815
+ subscribe(callback: (data: any, context: ChannelContext, updaterId: string) => void): UnsubscribeFunction;
816
+
817
+ /**
818
+ * Tracks the data in a given channel.
819
+ * @param name The channel to track.
820
+ * @param callback Callback function to handle the received data.
821
+ * @returns Promise that resolves with an unsubscribe function.
822
+ */
823
+ subscribeFor(name: string, callback: (data: any, context: ChannelContext, updaterId: string) => void): Promise<UnsubscribeFunction>;
824
+
825
+ /**
826
+ * Updates the context of the current or a given channel.
827
+ * @param data Data object with which to update the channel context.
828
+ * @param name The name of the channel to be updated. If not provided will update the current channel.
829
+ * @returns Promise that resolves when the data has been published.
830
+ */
831
+ publish(data: any, name?: string): Promise<void>;
832
+
833
+ /**
834
+ * Returns a list of all channel names.
835
+ * @returns Promise that resolves with the list of all channel names.
836
+ */
837
+ all(): Promise<string[]>;
838
+
839
+ /**
840
+ * Returns a list of all channel contexts.
841
+ * @returns Promise that resolves with the list of all channel contexts.
842
+ */
843
+ list(): Promise<ChannelContext[]>;
844
+
845
+ /**
846
+ * Returns the context of a given channel.
847
+ * @param name The name of the channel whose context to return.
848
+ * @returns Promise that resolves with the context of the given channel.
849
+ */
850
+ get(name: string): Promise<ChannelContext>;
851
+
852
+ /**
853
+ * Joins a new channel by name. Leaves the current channel.
854
+ * @param name The name of the channel to join.
855
+ * @returns Promise that resolves when the channel has been joined.
856
+ */
857
+ join(name: string): Promise<void>;
858
+
859
+ /**
860
+ * Leaves the current channel.
861
+ * @returns Promise that resolves when the channel has been left.
862
+ */
863
+ leave(): Promise<void>;
864
+
865
+ /**
866
+ * Returns the name of the current channel.
867
+ * @ignore
868
+ * @returns The name of the current channel.
869
+ */
870
+ current(): string;
871
+
872
+ /**
873
+ * Returns the name of the current channel.
874
+ * @returns The name of the current channel.
875
+ */
876
+ my(): string;
877
+
878
+ /**
879
+ * Subscribes for the event which fires when a channel is changed.
880
+ * @ignore
881
+ * @param callback Callback function to handle channel changes.
882
+ * @returns Unsubscribe function.
883
+ */
884
+ changed(callback: (channel: string) => void): UnsubscribeFunction;
885
+
886
+ /**
887
+ * Subscribes for the event which fires when a channel is changed.
888
+ * @param callback Callback function to handle channel changes.
889
+ * @returns Unsubscribe function.
890
+ */
891
+ onChanged(callback: (channel: string) => void): UnsubscribeFunction;
892
+
893
+ /**
894
+ * Adds a new channel.
895
+ * @ignore
896
+ * @param info The initial channel context.
897
+ * @returns Promise that resolves with the initial channel context.
898
+ */
899
+ add(info: ChannelContext): Promise<ChannelContext>;
900
+ }
901
+
902
+ /**
903
+ * Channel context object.
904
+ */
905
+ export interface ChannelContext {
906
+ /** Unique name of the context. */
907
+ name: string;
908
+ /** Channel meta data (display name, color, image, etc.) */
909
+ meta: any;
910
+ /** Channel data. */
911
+ data: any;
912
+ }
913
+ }
914
+
915
+ /**
916
+ * @docname App Management
917
+ * @intro
918
+ * The App Management API provides a way to manage **io.Connect Browser** apps. It offers abstractions for:
919
+ *
920
+ * - **Application** - a web app as a logical entity, registered in **io.Connect Browser** with some metadata (name, title, version, etc.) and with all the configuration needed to spawn one or more instances of it.
921
+ * The App Management API provides facilities for retrieving app metadata and for detecting when an application has been started;
922
+ *
923
+ * - **Instance** - a running copy of an app. The App Management API provides facilities for starting/stopping app instances and tracking app and instance related events;
924
+ *
925
+ * The App Management API is accessible through the `io.appManager` object.
926
+ */
927
+ namespace AppManager {
928
+ /**
929
+ * Application Management API.
930
+ */
931
+ export interface API {
932
+ /** The instance of the application. */
933
+ myInstance: Instance;
934
+
935
+ /** An object, through which applications definitions stored in-memory can be programmatically imported or removed. */
936
+ inMemory: InMemory;
937
+
938
+ /**
939
+ * Returns an application by name.
940
+ * @param name Name of the desired application.
941
+ * @returns The application.
942
+ */
943
+ application(name: string): Application;
944
+
945
+ /** Returns a list of all applications.
946
+ * @returns A list of all applications.
947
+ */
948
+ applications(): Application[];
949
+
950
+ /** Returns an array with all running application instances.
951
+ * @returns A list of all running application instances.
952
+ */
953
+ instances(): Instance[];
954
+
955
+ /**
956
+ * Notifies when a new application instance has been started.
957
+ * Replays the already started instances.
958
+ * @param callback Callback function to handle the event. Receives the started application instance as a parameter.
959
+ * @returns Unsubscribe function.
960
+ */
961
+ onInstanceStarted(callback: (instance: Instance) => any): UnsubscribeFunction;
962
+
963
+ /**
964
+ * Notifies when an application instance has been stopped.
965
+ * @param callback Callback function to handle the event. Receives the stopped application instance as a parameter.
966
+ * @returns Unsubscribe function.
967
+ */
968
+ onInstanceStopped(callback: (instance: Instance) => any): UnsubscribeFunction;
969
+
970
+ /**
971
+ * Notifies when an application is registered in the environment.
972
+ * Replays the already added applications.
973
+ * @param callback Callback function to handle the event. Receives the added application as a parameter.
974
+ * @returns Unsubscribe function.
975
+ */
976
+ onAppAdded(callback: (app: Application) => any): UnsubscribeFunction;
977
+
978
+ /**
979
+ * Notifies when the application is removed from the environment.
980
+ * @param callback Callback function to handle the event. Receives the removed application as a parameter.
981
+ * @returns Unsubscribe function.
982
+ */
983
+ onAppRemoved(callback: (app: Application) => any): UnsubscribeFunction;
984
+
985
+ /**
986
+ * Notifies when the configuration for an application has changed.
987
+ * @param callback Callback function to handle the event. Receives the changed application as a parameter.
988
+ * @returns Unsubscribe function.
989
+ */
990
+ onAppChanged(callback: (app: Application) => any): UnsubscribeFunction;
991
+ }
992
+
993
+ /** An object, through which applications definitions stored in-memory can be programmatically imported or removed. */
994
+ export interface InMemory {
995
+ /**
996
+ * Imports the provided collection of application definitions. Returns an import result object, which contains the names of the successfully imported apps and a list of errors if any.
997
+ * @param definitions A collection of application definition objects to be imported.
998
+ * @param mode Import mode, by default it is "replace". "replace" mode replaces all existing definitions with the provided collection, "merge" mode adds (if new) or updates (if already existing) the provided definitions.
999
+ */
1000
+ import(definitions: Definition[], mode?: "replace" | "merge"): Promise<ImportResult>;
1001
+
1002
+ /**
1003
+ * Removed an application definition. This method will fire onAppRemoved if a definition was removed and it will do nothing if an app with this was was not found.
1004
+ * @param name The name of the definition to be removed.
1005
+ */
1006
+ remove(name: string): Promise<void>;
1007
+
1008
+ /** Exports all known application definitions */
1009
+ export(): Promise<Definition[]>;
1010
+
1011
+ /** Removes all applications from the memory */
1012
+ clear(): Promise<void>;
1013
+ }
1014
+
1015
+ export interface ImportResult {
1016
+ /** A list of names of the successfully imported application definitions */
1017
+ imported: string[];
1018
+
1019
+ /** A list of application names and errors of all the unsuccessful imports */
1020
+ errors: Array<{ app: string; error: string }>;
1021
+ }
1022
+
1023
+ export interface DefinitionDetails {
1024
+ url: string;
1025
+
1026
+ /**
1027
+ * Distance of the top left window corner from the top edge of the screen.
1028
+ * @default 0
1029
+ */
1030
+ top?: number;
1031
+
1032
+ /**
1033
+ * Distance of the top left window corner from the left edge of the screen.
1034
+ * @default 0
1035
+ */
1036
+ left?: number;
1037
+
1038
+ /**
1039
+ * Window width.
1040
+ * @default 400
1041
+ */
1042
+ width?: number;
1043
+
1044
+ /**
1045
+ * Window height.
1046
+ * @default 400
1047
+ */
1048
+ height?: number;
1049
+ }
1050
+
1051
+ /**
1052
+ * An intent definition.
1053
+ */
1054
+ export interface Intent {
1055
+ /**
1056
+ * The name of the intent to 'launch'. In this case the name of an Intent supported by an Application.
1057
+ */
1058
+ name: string;
1059
+
1060
+ /**
1061
+ * An optional display name for the intent that may be used in UI instead of the name.
1062
+ */
1063
+ displayName?: string;
1064
+
1065
+ /**
1066
+ * A comma separated list of the types of contexts the intent offered by the application can process, here the first part of the context type is the namespace e.g."fdc3.contact, org.symphony.contact".
1067
+ */
1068
+ contexts?: string[];
1069
+
1070
+ /**
1071
+ * Custom configuration for the intent that may be required for a particular desktop agent.
1072
+ */
1073
+ customConfig?: object;
1074
+
1075
+ /**
1076
+ * Result type may be a type name, the string "channel" (which indicates that the app will return a channel) or a string indicating a channel that returns a specific type, e.g. "channel<fdc3.instrument>"
1077
+ */
1078
+ resultType?: string;
1079
+ }
1080
+
1081
+ export interface Definition {
1082
+ /**
1083
+ * Application name. Should be unique.
1084
+ */
1085
+ name: string;
1086
+
1087
+ /**
1088
+ * Type of the application - the only supported type in **io.Connect Browser** is "window". More complex types are available in **io.Connect Desktop**.
1089
+ */
1090
+ type: string;
1091
+
1092
+ /**
1093
+ * The title of the app. Sets the window's title.
1094
+ */
1095
+ title?: string;
1096
+
1097
+ /**
1098
+ * Application version.
1099
+ */
1100
+ version?: string;
1101
+
1102
+ /**
1103
+ * Detailed configuration.
1104
+ */
1105
+ details: DefinitionDetails;
1106
+
1107
+ /**
1108
+ * Generic object for passing properties, settings, etc., in the for of key/value pairs. Accessed using the app.userProperties property.
1109
+ */
1110
+ customProperties?: PropertiesObject;
1111
+
1112
+ /**
1113
+ * Application icon.
1114
+ */
1115
+ icon?: string;
1116
+
1117
+ /**
1118
+ * Application caption.
1119
+ */
1120
+ caption?: string;
1121
+
1122
+ /**
1123
+ * The list of intents implemented by the Application
1124
+ */
1125
+ intents?: Intent[];
1126
+
1127
+ /**
1128
+ * If set to true, the application will not be listed in the **io.Connect Browser** Launchpad. Defaults to false.
1129
+ */
1130
+ hidden?: boolean;
1131
+ }
1132
+
1133
+ /** Object describing an app. */
1134
+ export interface Application {
1135
+ /** Application name. */
1136
+ name: string;
1137
+
1138
+ /** Application title. */
1139
+ title?: string;
1140
+
1141
+ /** Application version. */
1142
+ version?: string;
1143
+
1144
+ /** Application icon. */
1145
+ icon?: string;
1146
+
1147
+ /** Application caption. */
1148
+ caption?: string;
1149
+
1150
+ /** Generic object for passing properties, settings, etc., in the for of key/value pairs. */
1151
+ userProperties: PropertiesObject;
1152
+
1153
+ /** Instances of that app. */
1154
+ instances: Instance[];
1155
+
1156
+ /**
1157
+ * Returns the newly started application instance.
1158
+ * @param context The initial context of the application.
1159
+ * @param options Options object in which you can specify window setting (that will override the default configuration settings), as well as other additional options.
1160
+ * @returns Promise that resolves with the newly started application instance.
1161
+ */
1162
+ start(context?: object, options?: ApplicationStartOptions): Promise<Instance>;
1163
+
1164
+ /**
1165
+ * Subscribes for the event which fires when an application instance is started.
1166
+ * Note: unlike the API's `onInstanceStarted()` the Application's `onInstanceStarted()` method doesn't replay the already started instances.
1167
+ * @param callback Callback function to handle the newly started instance.
1168
+ * @returns Unsubscribe function.
1169
+ */
1170
+ onInstanceStarted(callback: (instance: Instance) => any): UnsubscribeFunction;
1171
+
1172
+ /**
1173
+ * Subscribes for the event which fires when an application instance is stopped.
1174
+ * @param callback Callback function to handle the newly started instance.
1175
+ * @returns Unsubscribe function.
1176
+ */
1177
+ onInstanceStopped(callback: (instance: Instance) => any): UnsubscribeFunction;
1178
+ }
1179
+
1180
+ /**
1181
+ * Object with options for starting an application.
1182
+ */
1183
+ export interface ApplicationStartOptions {
1184
+
1185
+ /**
1186
+ * Distance of the top left window corner from the top edge of the screen.
1187
+ * @default 0
1188
+ */
1189
+ top?: number;
1190
+
1191
+ /**
1192
+ * Distance of the top left window corner from the left edge of the screen.
1193
+ * @default 0
1194
+ */
1195
+ left?: number;
1196
+
1197
+ /**
1198
+ * Window width.
1199
+ * @default 400
1200
+ */
1201
+ width?: number;
1202
+
1203
+ /**
1204
+ * Window height.
1205
+ * @default 400
1206
+ */
1207
+ height?: number;
1208
+
1209
+ /**
1210
+ * The ID of the window that will be used to relatively position the new window.
1211
+ * Can be combined with `relativeDirection`.
1212
+ */
1213
+ relativeTo?: string;
1214
+
1215
+ /**
1216
+ * Direction (`"bottom"`, `"top"`, `"left"`, `"right"`) of positioning the window relatively to the `relativeTo` window. Considered only if `relativeTo` is supplied.
1217
+ * @default "right"
1218
+ */
1219
+ relativeDirection?: "top" | "left" | "right" | "bottom";
1220
+
1221
+ waitForAGMReady?: boolean;
1222
+ }
1223
+
1224
+ /** Generic object for passing properties, settings, etc., in the for of key/value pairs. */
1225
+ export interface PropertiesObject {
1226
+ [key: string]: any;
1227
+ }
1228
+
1229
+ /** Object describing an application instance. */
1230
+ export interface Instance {
1231
+ /** Instance ID. */
1232
+ id: string;
1233
+
1234
+ /** The starting context of the instance. */
1235
+ getContext(): Promise<object>;
1236
+
1237
+ /** Interop instance. Use this to invoke Interop methods for that instance. */
1238
+ agm: Interop.Instance;
1239
+
1240
+ application: Application;
1241
+
1242
+ /** Stops the instance.
1243
+ * @returns Promise that resolves when the instance has been stopped.
1244
+ */
1245
+ stop(): Promise<void>;
1246
+ }
1247
+ }
1248
+
1249
+ /**
1250
+ * @intro
1251
+ * In certain workflow scenarios, your application may need to start (or activate) a specific application.
1252
+ * For instance, you may have an application showing client portfolios with financial instruments.
1253
+ * When the user clicks on an instrument, you want to start an application which shows a chart for that instrument.
1254
+ * In other cases, you may want to present the user with several options for executing an action or handling data from the current application.
1255
+ *
1256
+ * The Intents API makes all that possible by enabling applications to register, find and raise Intents.
1257
+ *
1258
+ * The Intents API is accessible through the `io.intents` object.
1259
+ */
1260
+ namespace Intents {
1261
+ export interface API {
1262
+ /**
1263
+ * Raises an intent, optionally passing context to the intent handlers, and optionally targeting specific intent handlers.
1264
+ * If no handlers are matching the targeting conditions the promise will be rejected.
1265
+ * @param request can be the intent's name or an IntentRequest object carrying the intent, and its optional target, context and start options (see "startNew").
1266
+ * @returns Promise that resolves with IntentResult.
1267
+ */
1268
+ raise(request: string | IntentRequest): Promise<IntentResult>;
1269
+
1270
+ /**
1271
+ * Returns all registered Intent.
1272
+ * @returns Promise that resolves with all registered intents.
1273
+ */
1274
+ all(): Promise<Intent[]>;
1275
+
1276
+ /**
1277
+ * @ignore
1278
+ * @deprecated Use register() method instead
1279
+ *
1280
+ * If your application is an intent handler use this method to handle incoming intent requests.
1281
+ * Please note that when a new instance of your application is started as a result of a raised intent with
1282
+ * e.g. `startNew` your application needs to call `addIntentListener()` on startup so that the intent can be resolved.
1283
+ * The handler callback will be invoked whenever an intent is raised and your app was selected as an IntentTarget.
1284
+ * You can also use this method to register new dynamic intents, that will have the the same lifespan as your application instance.
1285
+ * @param intent The intent to be handled. The intent name of an object containing the intent, contextTypes that the intent can handle and a display name.
1286
+ * @param handler The callback that will handle a raised intent. Will be called with an IntentContext if it is provided by the raising application.
1287
+ * @returns An object with an unsubscribe function under the unsubscribe property.
1288
+ */
1289
+ addIntentListener(intent: string | AddIntentListenerRequest, handler: (context: IntentContext) => any): { unsubscribe: UnsubscribeFunction };
1290
+
1291
+ /**
1292
+ * If your application is an intent handler use this method to handle incoming intent requests.
1293
+ * Please note that when a new instance of your application is started as a result of a raised intent with
1294
+ * e.g. `startNew` your application needs to call `register()` on startup so that the intent can be resolved.
1295
+ * The handler callback will be invoked whenever an intent is raised and your app was selected as an IntentTarget.
1296
+ * You can also use this method to register new dynamic intents, that will have the the same lifespan as your application instance.
1297
+ * @param intent The intent to be handled. The intent name of an object containing the intent, contextTypes that the intent can handle and a display name.
1298
+ * @param handler The callback that will handle a raised intent. Will be called with an IntentContext if it is provided by the raising application.
1299
+ * @returns Promise that resolves to an object with an unsubscribe function under the unsubscribe property.
1300
+ */
1301
+ register(intent: string | AddIntentListenerRequest, handler: (context: IntentContext) => any): Promise<{ unsubscribe: UnsubscribeFunction }>;
1302
+
1303
+ /**
1304
+ * Searches for registered intents.
1305
+ * @param intentFilter can be the intent name or a IntentFilter filtering criteria.
1306
+ * @returns Promise that resolves with the found intents that match the provided filtering criteria.
1307
+ */
1308
+ find(intentFilter?: string | IntentFilter): Promise<Intent[]>;
1309
+
1310
+ /**
1311
+ * An object, through which IntentsResolver API is exposed.
1312
+ */
1313
+ resolver?: Resolver
1314
+ }
1315
+ export interface Config {
1316
+ /**
1317
+ * Whether to use Intents Resolver UI to handle raising an intent.
1318
+ * The UI provides the user with a list of all available applications and running instances which can handle the raised intent.
1319
+ * Default value: true
1320
+ */
1321
+ enableIntentsResolverUI?: boolean;
1322
+
1323
+ /**
1324
+ * Specify your custom application name for Intents Resolver UI which will open when io.intents.raise() is invoked.
1325
+ * If not provided, Intents API will use the default Intents Resolver UI application to handle raising an intent with multiple handlers
1326
+ */
1327
+ intentsResolverAppName?: string;
1328
+
1329
+ /**
1330
+ * Timeout to wait for response from Intents Resolver UI
1331
+ * @default 60000
1332
+ */
1333
+ methodResponseTimeoutMs?: number;
1334
+ }
1335
+
1336
+ interface ResolverIntentHandler {
1337
+ applicationName: string;
1338
+ applicationIcon?: string;
1339
+ instanceId?: string;
1340
+ }
1341
+
1342
+ export interface Resolver {
1343
+ /**
1344
+ * Name of the raised intent
1345
+ */
1346
+ intent: string;
1347
+
1348
+ /**
1349
+ * Notifies when a ResolverIntentHandler of the current intent is added. Replays the already existing handlers.
1350
+ */
1351
+ onHandlerAdded(callback: (handler: ResolverIntentHandler) => void): UnsubscribeFunction;
1352
+
1353
+ /**
1354
+ * Notifies when a ResolverIntentHandler of the current intent is removed.
1355
+ */
1356
+ onHandlerRemoved(callback: (removedHandler: ResolverIntentHandler) => void): UnsubscribeFunction;
1357
+
1358
+ /**
1359
+ * Sends the chosen handler to the application which raised the intent
1360
+ */
1361
+ sendResponse(handler: ResolverIntentHandler): Promise<IOConnectCore.Interop.InvocationResult | undefined>;
1362
+ }
1363
+
1364
+ /**
1365
+ *
1366
+ * Use to define dynamic intents, that will have the same lifespan as your application instance
1367
+ * */
1368
+ export interface AddIntentListenerRequest {
1369
+ intent: string;
1370
+ contextTypes?: string[];
1371
+ displayName?: string;
1372
+ icon?: string;
1373
+ description?: string;
1374
+ resultType?: string;
1375
+ }
1376
+
1377
+ /**
1378
+ * Specifies the search criteria for the Intent API's `find()` method.
1379
+ */
1380
+ export interface IntentFilter {
1381
+ /**
1382
+ * The name of the intent to be used in the lookup.
1383
+ */
1384
+ name?: string;
1385
+ /**
1386
+ * The name of the context type to be used in the lookup.
1387
+ */
1388
+ contextType?: string;
1389
+ /**
1390
+ * The type of the intent result to be used in the lookup.
1391
+ */
1392
+ resultType?: string;
1393
+ }
1394
+
1395
+ /**
1396
+ * Represents an intent.
1397
+ */
1398
+ export interface Intent {
1399
+ /**
1400
+ * The name of the intent, such as `"CreateCall"`.
1401
+ */
1402
+ name: string;
1403
+ /**
1404
+ * The set of IntentHandler that provide an implementation for the intent and can be used to handle an intent request.
1405
+ */
1406
+ handlers: IntentHandler[];
1407
+ }
1408
+
1409
+ /**
1410
+ * Represents an implementation of an intent.
1411
+ * Each intent handler can offer its own display name - this allows context menus
1412
+ * built on the fly to display more user friendly options. For example, if there is
1413
+ * an intent with a name "ShowNews", there could be a handler with display name
1414
+ * "Show Bloomberg News" and another with display name "Show Reuters News".
1415
+ * Handlers can optionally specify the context type they support, where the
1416
+ * context type is the name of a typed, documented data structure such as
1417
+ * "Person", "Team", "Instrument", "Order", etc. In the example above,
1418
+ * both the Bloomberg and Reuters handlers would specify a context type "Instrument" and
1419
+ * would expect to be raised with an instrument object conforming to an expected
1420
+ * structure from both handlers.
1421
+ * An intent handler must not necessarily specify a context type.
1422
+ */
1423
+ export interface IntentHandler {
1424
+ /**
1425
+ * The name of the application which registered this intent implementation, as specified in the application configuration.
1426
+ */
1427
+ applicationName: string;
1428
+
1429
+ /* The title of the application which registered this intent implementation, as specified in the application configuration. */
1430
+ applicationTitle: string;
1431
+
1432
+ /* User friendly (longer) description of the application, as specified in the application configuration. */
1433
+ applicationDescription?: string;
1434
+
1435
+ /* Icon URL of the application that has registered the intent handler, as specified in the application configuration. */
1436
+ applicationIcon?: string;
1437
+
1438
+ /**
1439
+ * The type of the handler.
1440
+ * "app" - An application that has declared itself as an implementor of the intent inside of its application definition.
1441
+ * "instance" - A running instance of an application that can handle the intent. Also includes dynamically added intents using `addIntentListener()`.
1442
+ */
1443
+ type: "app" | "instance";
1444
+
1445
+ /**
1446
+ * The human-readable name of the intent handler, as specified in the intent definition.
1447
+ */
1448
+ displayName?: string;
1449
+
1450
+ /**
1451
+ * The context types this handler supports.
1452
+ */
1453
+ contextTypes?: string[];
1454
+
1455
+ /**
1456
+ * The id of the running application instance.
1457
+ */
1458
+ instanceId?: string;
1459
+
1460
+ /**
1461
+ * The window's title of the running application instance.
1462
+ */
1463
+ instanceTitle?: string;
1464
+
1465
+ /**
1466
+ * Result type may be a type name, the string "channel" (which indicates that the app will return a channel)
1467
+ * or a string indicating a channel that returns a specific type, e.g. "channel<fdc3.instrument>"
1468
+ */
1469
+ resultType?: string;
1470
+ }
1471
+
1472
+ /**
1473
+ * Represents a request to raise an intent.
1474
+ */
1475
+ export interface IntentRequest {
1476
+ /**
1477
+ * The name of the intent to be raised.
1478
+ */
1479
+ readonly intent: string;
1480
+ /**
1481
+ * Тhe target of the raised intent. Valid values are:
1482
+ * `startNew` - will start a new instance of an application that can handle the intent.
1483
+ * `reuse` - a running instance of an application will handle the intent.
1484
+ * { app: "AppName" } - will start a new instance of the "AppName" application (iff it can handle it) that will handle the intent.
1485
+ * { instance: "i-123-1" } - the running application instance with instanceId "i-123-1" will handle the intent (iff it can handle it).
1486
+ */
1487
+ readonly target?: "startNew" | "reuse" | { app?: string; instance?: string };
1488
+ /**
1489
+ * The context type and data that will be provided to the intent implementation's handler.
1490
+ */
1491
+ readonly context?: IntentContext;
1492
+ /**
1493
+ * Start up options that will be used when a new instance of an application needs to be started to handle the intent request.
1494
+ */
1495
+ readonly options?: AppManager.ApplicationStartOptions;
1496
+ /**
1497
+ * List of Intent Handlers which will be provided to the user via Intents Resolver UI. If the Resolver is disabled or there's only one handler
1498
+ * in the array, raise() will resolve with the first application or instance in the collection.
1499
+ */
1500
+ readonly handlers?: IOConnectBrowser.Intents.IntentHandler[];
1501
+ /**
1502
+ * Timeout to wait for 'raise' method to resolve.
1503
+ * @default: 90000
1504
+ */
1505
+ readonly timeout?: number;
1506
+ /**
1507
+ * Whether to wait for the Intents Resolver UI to choose a handler for the raised intent.
1508
+ * If set to true, the timer starts after there's a chosen handler from the user.
1509
+ * Otherwise, the start point is the beginning of the raise invocation.
1510
+ * @default: false
1511
+ */
1512
+ readonly waitUserResponseIndefinitely?: boolean;
1513
+ }
1514
+
1515
+ /**
1516
+ * A structure that describes a typed context to be used to raise intents with.
1517
+ */
1518
+ export interface IntentContext {
1519
+ /**
1520
+ * The name of a typed, documented data structure such as "Person", "Team", "Instrument", "Order", etc.
1521
+ * It is the application developers' job to agree on a protocol to follow.
1522
+ */
1523
+ readonly type?: string;
1524
+ /**
1525
+ * The context data used as an argument by the intent implementation.
1526
+ */
1527
+ readonly data?: { [key: string]: any };
1528
+ }
1529
+
1530
+ /**
1531
+ * The result of a raised intent.
1532
+ */
1533
+ export interface IntentResult {
1534
+ /**
1535
+ * The arguments that were used to raise the intent with.
1536
+ */
1537
+ request: IntentRequest;
1538
+ /**
1539
+ * The intent implementation that handled the intent.
1540
+ */
1541
+ handler: IntentHandler;
1542
+ /**
1543
+ * The data returned by the intent implementation when handling the intent.
1544
+ */
1545
+ result?: any;
1546
+ }
1547
+ }
1548
+
1549
+ /**
1550
+ * @intro
1551
+ * **io.Connect Browser** has two built-in themes - "Day" and "Night". You can control the themes programmatically by using the Themes API.
1552
+ *
1553
+ * The Themes API is accessible through the `io.themes` object.
1554
+ */
1555
+ namespace Themes {
1556
+ export interface API {
1557
+ /**
1558
+ * Returns the current theme.
1559
+ * @param request can be the intent's name or an IntentRequest object carrying the intent, and its optional target, context and start options (see "startNew").
1560
+ * @returns Promise that resolves with IntentResult.
1561
+ */
1562
+ getCurrent(): Promise<Theme>;
1563
+
1564
+ /**
1565
+ * Returns list of available themes
1566
+ */
1567
+ list(): Promise<Theme[]>;
1568
+
1569
+ /**
1570
+ * Notifies you when the theme is changed.
1571
+ * @param callback Callback to handle the event. Receives the theme object as an argument.
1572
+ */
1573
+ onChanged(callback: (theme: Theme) => any): void;
1574
+
1575
+ /**
1576
+ * Selects a new theme
1577
+ * @param name The name of the theme
1578
+ */
1579
+ select(name: string): Promise<void>;
1580
+ }
1581
+
1582
+ export interface Theme {
1583
+ displayName: string;
1584
+ name: string;
1585
+ }
1586
+ }
1587
+
1588
+ /**
1589
+ * @ignore
1590
+ */
1591
+ namespace WebPlatform {
1592
+ export interface API {
1593
+ version: string;
1594
+
1595
+ system: System;
1596
+
1597
+ corePlus?: CorePlus;
1598
+ }
1599
+
1600
+ export interface System {
1601
+ /**
1602
+ * Shuts down the web platform, clears the IO Connect session data and closes all windows.
1603
+ */
1604
+ shutdown(): Promise<void>;
1605
+ }
1606
+
1607
+ export interface CorePlus {
1608
+ version: string;
1609
+ }
1610
+ }
1611
+ }