@openfin/core 38.81.34 → 38.81.37

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/out/fdc3.d.ts ADDED
@@ -0,0 +1,1964 @@
1
+ /**
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Copyright FINOS FDC3 contributors - see NOTICE file
4
+ */
5
+ /**
6
+ * Identifies an application, or instance of an application, and is used to target FDC3 API calls, such as `fdc3.open` or `fdc3.raiseIntent` at specific applications or application instances.
7
+ *
8
+ * Will always include at least an `appId` field, which uniquely identifies a specific app.
9
+ *
10
+ * If the `instanceId` field is set then the `AppMetadata` object represents a specific instance of the application that may be addressed using that Id.
11
+ */
12
+ declare interface AppIdentifier {
13
+ /** The unique application identifier located within a specific application directory instance. An example of an appId might be 'app@sub.root' */
14
+ readonly appId: string;
15
+ /** An optional instance identifier, indicating that this object represents a specific instance of the application described.*/
16
+ readonly instanceId?: string;
17
+ }
18
+
19
+ /**
20
+ * An interface that relates an intent to apps
21
+ */
22
+ declare interface AppIntent {
23
+ readonly intent: IntentMetadata;
24
+ readonly apps: Array<AppMetadata>;
25
+ }
26
+
27
+ /**
28
+ * An interface that relates an intent to apps
29
+ */
30
+ declare interface AppIntent_2 {
31
+ /** Details of the intent whose relationship to resolving applications is being described. */
32
+ readonly intent: IntentMetadata_2;
33
+ /** Details of applications that can resolve the intent. */
34
+ readonly apps: Array<AppMetadata_2>;
35
+ }
36
+
37
+ /**
38
+ * SPDX-License-Identifier: Apache-2.0
39
+ * Copyright 2019 FINOS FDC3 contributors - see NOTICE file
40
+ */
41
+ /**
42
+ * App definition as provided by the application directory
43
+ */
44
+ declare interface AppMetadata {
45
+ /** The unique app name that can be used with the open and raiseIntent calls. */
46
+ readonly name: string;
47
+ /** The unique application identifier located within a specific application directory instance. An example of an appId might be 'app@sub.root' */
48
+ readonly appId?: string;
49
+ /** The Version of the application. */
50
+ readonly version?: string;
51
+ /** A more user-friendly application title that can be used to render UI elements */
52
+ readonly title?: string;
53
+ /** A tooltip for the application that can be used to render UI elements */
54
+ readonly tooltip?: string;
55
+ /** A longer, multi-paragraph description for the application that could include markup */
56
+ readonly description?: string;
57
+ /** A list of icon URLs for the application that can be used to render UI elements */
58
+ readonly icons?: Array<string>;
59
+ /** A list of image URLs for the application that can be used to render UI elements */
60
+ readonly images?: Array<string>;
61
+ }
62
+
63
+ /**
64
+ * Extends an `AppIdentifier`, describing an application or instance of an application, with additional descriptive metadata that is usually provided by an FDC3 App Directory that the desktop agent connects to.
65
+ *
66
+ * The additional information from an app directory can aid in rendering UI elements, such as a launcher menu or resolver UI. This includes a title, description, tooltip and icon and screenshot URLs.
67
+ *
68
+ * Note that as `AppMetadata` instances are also `AppIdentifiers` they may be passed to the `app` argument of `fdc3.open`, `fdc3.raiseIntent` etc.
69
+ */
70
+ declare interface AppMetadata_2 extends AppIdentifier {
71
+ /**
72
+ The 'friendly' app name.
73
+ This field was used with the `open` and `raiseIntent` calls in FDC3 <2.0, which now require an `AppIdentifier` wth `appId` set.
74
+ Note that for display purposes the `title` field should be used, if set, in preference to this field.
75
+ */
76
+ readonly name?: string;
77
+ /** The Version of the application. */
78
+ readonly version?: string;
79
+ /** An optional set of, implementation specific, metadata fields that can be used to disambiguate instances, such as a window title or screen position. Must only be set if `instanceId` is set. */
80
+ readonly instanceMetadata?: Record<string, any>;
81
+ /** A more user-friendly application title that can be used to render UI elements */
82
+ readonly title?: string;
83
+ /** A tooltip for the application that can be used to render UI elements */
84
+ readonly tooltip?: string;
85
+ /** A longer, multi-paragraph description for the application that could include markup */
86
+ readonly description?: string;
87
+ /** A list of icon URLs for the application that can be used to render UI elements */
88
+ readonly icons?: Array<Icon>;
89
+ /** Images representing the app in common usage scenarios that can be used to render UI elements */
90
+ readonly screenshots?: Array<Image_2>;
91
+ /** The type of output returned for any intent specified during resolution. May express a particular context type (e.g. "fdc3.instrument"), channel (e.g. "channel") or a channel that will receive a specified type (e.g. "channel<fdc3.instrument>"). */
92
+ readonly resultType?: string | null;
93
+ }
94
+
95
+ /**
96
+ * Object representing a context channel.
97
+ */
98
+ declare interface Channel {
99
+ /**
100
+ * Constant that uniquely identifies this channel.
101
+ */
102
+ readonly id: string;
103
+ /**
104
+ * Uniquely defines each channel type.
105
+ */
106
+ readonly type: string;
107
+ /**
108
+ * Channels may be visualized and selectable by users. DisplayMetadata may be used to provide hints on how to see them.
109
+ * For app channels, displayMetadata would typically not be present
110
+ */
111
+ readonly displayMetadata?: DisplayMetadata;
112
+ /**
113
+ * Broadcasts the given context on this channel. This is equivalent to joining the channel and then calling the
114
+ * top-level FDC3 `broadcast` function.
115
+ *
116
+ * Note that this function can be used without first joining the channel, allowing applications to broadcast on
117
+ * channels that they aren't a member of.
118
+ *
119
+ * Channel implementations should ensure that context messages broadcast by an application on a channel should
120
+ * not be delivered back to that same application if they are joined to the channel.
121
+ *
122
+ * `Error` with a string from the `ChannelError` enumeration.
123
+ */
124
+ broadcast(context: Context): void;
125
+ /**
126
+ * Returns the last context that was broadcast on this channel. All channels initially have no context, until a
127
+ * context is broadcast on the channel. If there is not yet any context on the channel, this method
128
+ * will return `null`.
129
+ *
130
+ * The context of a channel will be captured regardless of how the context is broadcasted on this channel - whether
131
+ * using the top-level FDC3 `broadcast` function, or using the channel-level {@link broadcast} function on this
132
+ * object.
133
+ *
134
+ * Optionally a {@link contextType} can be provided, in which case the current context of the matching type will
135
+ * be returned (if any). Desktop agent implementations may decide to record contexts by type, in which case it will
136
+ * be possible to get the most recent context of the type specified, but this is not guaranteed.
137
+ *
138
+ * `Error` with a string from the `ChannelError` enumeration.
139
+ */
140
+ getCurrentContext(contextType?: string): Promise<Context | null>;
141
+ /**
142
+ * Adds a listener for incoming contexts whenever a broadcast happens on this channel.
143
+ * @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`.
144
+ */
145
+ addContextListener(handler: ContextHandler): Listener;
146
+ /**
147
+ * Adds a listener for incoming contexts of the specified context type whenever a broadcast happens on this channel.
148
+ */
149
+ addContextListener(contextType: string | null, handler: ContextHandler): Listener;
150
+ }
151
+
152
+ /**
153
+ * Represents a context channel that applications can use to send and receive
154
+ * context data.
155
+ *
156
+ * Please note that There are differences in behavior when you interact with a
157
+ * User channel via the `DesktopAgent` interface and the `Channel` interface.
158
+ * Specifically, when 'joining' a User channel or adding a context listener
159
+ * when already joined to a channel via the `DesktopAgent` interface, existing
160
+ * context (matching the type of the context listener) on the channel is
161
+ * received by the context listener immediately. Whereas, when a context
162
+ * listener is added via the Channel interface, context is not received
163
+ * automatically, but may be retrieved manually via the `getCurrentContext()`
164
+ * function.
165
+ */
166
+ declare interface Channel_2 {
167
+ /**
168
+ * Constant that uniquely identifies this channel.
169
+ */
170
+ readonly id: string;
171
+ /**
172
+ * Uniquely defines each channel type.
173
+ * Can be "user", "app" or "private".
174
+ */
175
+ readonly type: 'user' | 'app' | 'private';
176
+ /**
177
+ * Channels may be visualized and selectable by users. DisplayMetadata may be used to provide hints on how to see them.
178
+ * For App channels, displayMetadata would typically not be present.
179
+ */
180
+ readonly displayMetadata?: DisplayMetadata_2;
181
+ /**
182
+ * Broadcasts a context on the channel. This function can be used without first joining the channel, allowing applications to broadcast on both App Channels and User Channels that they aren't a member of.
183
+ *
184
+ * If the broadcast is denied by the channel or the channel is not available, the promise will be rejected with an `Error` with a `message` string from the `ChannelError` enumeration.
185
+ *
186
+ * Channel implementations should ensure that context messages broadcast by an application on a channel should not be delivered back to that same application if they are joined to the channel.
187
+ *
188
+ * If you are working with complex context types composed of other simpler types (as recommended by the FDC3 Context Data specification) then you should broadcast each individual type (starting with the simpler types, followed by the complex type) that you want other apps to be able to respond to. Doing so allows applications to filter the context types they receive by adding listeners for specific context types.
189
+ *
190
+ * If an application attempts to broadcast an invalid context argument the Promise returned by this function should reject with the `ChannelError.MalformedContext` error.
191
+ */
192
+ broadcast(context: Context_2): Promise<void>;
193
+ /**
194
+ * When a `contextType`_` is provided, the most recent context matching the type will be returned, or `null` if no matching context is found.
195
+ *
196
+ * If no `contextType` is provided, the most recent context that was broadcast on the channel - regardless of type - will be returned. If no context has been set on the channel, it will return `null`.
197
+ *
198
+ * It is up to the specific Desktop Agent implementation whether and how recent contexts are stored. For example, an implementation could store context history for a channel in a single array and search through the array for the last context matching a provided type, or context could be maintained as a dictionary keyed by context types. An implementation could also choose not to support context history, in which case this method will return `null` for any context type not matching the type of the most recent context.
199
+ *
200
+ * If getting the current context fails, the promise will be rejected with an `Error` with a `message` string from the `ChannelError` enumeration.
201
+ */
202
+ getCurrentContext(contextType?: string): Promise<Context_2 | null>;
203
+ /**
204
+ * Adds a listener for incoming contexts of the specified _context type_ whenever a broadcast happens on this channel.
205
+ *
206
+ * If, when this function is called, the channel already contains context that would be passed to the listener it is NOT called or passed this context automatically (this behavior differs from that of the [`fdc3.addContextListener`](DesktopAgent#addcontextlistener) function). Apps wishing to access to the current context of the channel should instead call the `getCurrentContext(contextType)` function.
207
+ *
208
+ * Optional metadata about each context message received, including the app that originated the message, SHOULD be provided by the desktop agent implementation.
209
+ */
210
+ addContextListener(contextType: string | null, handler: ContextHandler_2): Promise<Listener_2>;
211
+ /**
212
+ * @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`.
213
+ */
214
+ addContextListener(handler: ContextHandler_2): Promise<Listener_2>;
215
+ }
216
+
217
+ declare enum ChannelError {
218
+ NoChannelFound = "NoChannelFound",
219
+ AccessDenied = "AccessDenied",
220
+ CreationFailed = "CreationFailed"
221
+ }
222
+
223
+ declare enum ChannelError_2 {
224
+ /** Returned if the specified channel is not found when attempting to join a channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).*/
225
+ NoChannelFound = "NoChannelFound",
226
+ /** SHOULD be returned when a request to join a user channel or to a retrieve a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods of the DesktopAgent (`fdc3`) object is denied. */
227
+ AccessDenied = "AccessDenied",
228
+ /** SHOULD be returned when a channel cannot be created or retrieved via the `getOrCreateChannel` method of the DesktopAgent (`fdc3`).*/
229
+ CreationFailed = "CreationFailed",
230
+ /** Returned if a call to the `broadcast` functions is made with an invalid context argument. Contexts should be Objects with at least a `type` field that has a `string` value.*/
231
+ MalformedContext = "MalformedContext"
232
+ }
233
+
234
+ declare interface Chart {
235
+ instruments: InstrumentElement[];
236
+ otherConfig?: {
237
+ [key: string]: any;
238
+ };
239
+ range?: TimeRangeObject;
240
+ style?: Style;
241
+ type: string;
242
+ id?: {
243
+ [key: string]: any;
244
+ };
245
+ name?: string;
246
+ [property: string]: any;
247
+ }
248
+
249
+ declare interface ChatInitSettings {
250
+ chatName?: string;
251
+ initMessage?: string;
252
+ members?: ContactListObject;
253
+ options?: any;
254
+ type: any;
255
+ [property: string]: any;
256
+ }
257
+
258
+ declare interface Contact {
259
+ id: ContactID;
260
+ type: string;
261
+ name?: string;
262
+ }
263
+
264
+ declare interface Contact_2 {
265
+ id: TentacledID;
266
+ type: string;
267
+ name?: string;
268
+ [property: string]: any;
269
+ }
270
+
271
+ declare interface ContactElement {
272
+ id: FluffyID;
273
+ type: string;
274
+ name?: string;
275
+ [property: string]: any;
276
+ }
277
+
278
+ declare interface ContactID {
279
+ email?: string;
280
+ FDS_ID?: string;
281
+ }
282
+
283
+ declare interface ContactList {
284
+ contacts: Contact[];
285
+ type: string;
286
+ id?: {
287
+ [key: string]: string;
288
+ };
289
+ name?: string;
290
+ }
291
+
292
+ declare interface ContactList_2 {
293
+ contacts: ContactElement[];
294
+ type: string;
295
+ id?: {
296
+ [key: string]: any;
297
+ };
298
+ name?: string;
299
+ [property: string]: any;
300
+ }
301
+
302
+ declare interface ContactListObject {
303
+ contacts: ContactElement[];
304
+ type: string;
305
+ id?: {
306
+ [key: string]: any;
307
+ };
308
+ name?: string;
309
+ [property: string]: any;
310
+ }
311
+
312
+ declare interface Context {
313
+ id?: {
314
+ [key: string]: string;
315
+ };
316
+ name?: string;
317
+ type: string;
318
+ }
319
+
320
+ declare interface Context_2 {
321
+ id?: {
322
+ [key: string]: any;
323
+ };
324
+ name?: string;
325
+ type: string;
326
+ [property: string]: any;
327
+ }
328
+
329
+ declare type ContextHandler = (context: Context) => void;
330
+
331
+ /**
332
+ * Describes a callback that handles a context event.
333
+ * Used when attaching listeners for context broadcasts.
334
+ *
335
+ * Optional metadata about the context message, including the app that originated
336
+ * the message, SHOULD be provided by the desktop agent implementation.
337
+ */
338
+ declare type ContextHandler_2 = (context: Context_2, metadata?: ContextMetadata) => void;
339
+
340
+ /**
341
+ * Metadata relating to a context or intent and context received through the
342
+ * `addContextListener` and `addIntentListener` functions.
343
+ *
344
+ * @experimental Introduced in FDC3 2.0 and may be refined by further changes outside the normal FDC3 versioning policy.
345
+ */
346
+ declare interface ContextMetadata {
347
+ /** Identifier for the app instance that sent the context and/or intent.
348
+ *
349
+ * @experimental
350
+ */
351
+ readonly source: AppIdentifier;
352
+ }
353
+
354
+ declare type ContextType = ContextTypes | string;
355
+
356
+ declare type ContextType_2 = ContextTypes_2 | string;
357
+
358
+ declare enum ContextTypes {
359
+ Contact = "fdc3.contact",
360
+ ContactList = "fdc3.contactList",
361
+ Country = "fdc3.country",
362
+ Instrument = "fdc3.instrument",
363
+ Organization = "fdc3.organization",
364
+ Portfolio = "fdc3.portfolio",
365
+ Position = "fdc3.position"
366
+ }
367
+
368
+ declare enum ContextTypes_2 {
369
+ Chart = "fdc3.chart",
370
+ ChatInitSettings = "fdc3.chat.initSettings",
371
+ Contact = "fdc3.contact",
372
+ ContactList = "fdc3.contactList",
373
+ Country = "fdc3.country",
374
+ Currency = "fdc3.currency",
375
+ Email = "fdc3.email",
376
+ Instrument = "fdc3.instrument",
377
+ InstrumentList = "fdc3.instrumentList",
378
+ Organization = "fdc3.organization",
379
+ Portfolio = "fdc3.portfolio",
380
+ Position = "fdc3.position",
381
+ Nothing = "fdc3.nothing",
382
+ TimeRange = "fdc3.timerange",
383
+ Valuation = "fdc3.valuation"
384
+ }
385
+
386
+ declare class Convert {
387
+ static toContext(json: string): Context;
388
+ static contextToJson(value: Context): string;
389
+ static toContact(json: string): Contact;
390
+ static contactToJson(value: Contact): string;
391
+ static toContactList(json: string): ContactList;
392
+ static contactListToJson(value: ContactList): string;
393
+ static toInstrument(json: string): Instrument;
394
+ static instrumentToJson(value: Instrument): string;
395
+ static toInstrumentList(json: string): InstrumentList;
396
+ static instrumentListToJson(value: InstrumentList): string;
397
+ static toCountry(json: string): Country;
398
+ static countryToJson(value: Country): string;
399
+ static toOrganization(json: string): Organization;
400
+ static organizationToJson(value: Organization): string;
401
+ static toPortfolio(json: string): Portfolio;
402
+ static portfolioToJson(value: Portfolio): string;
403
+ static toPosition(json: string): Position;
404
+ static positionToJson(value: Position): string;
405
+ }
406
+
407
+ declare class Convert_2 {
408
+ static toChart(json: string): Chart;
409
+ static chartToJson(value: Chart): string;
410
+ static toChatInitSettings(json: string): ChatInitSettings;
411
+ static chatInitSettingsToJson(value: ChatInitSettings): string;
412
+ static toContact(json: string): Contact_2;
413
+ static contactToJson(value: Contact_2): string;
414
+ static toContactList(json: string): ContactList_2;
415
+ static contactListToJson(value: ContactList_2): string;
416
+ static toContext(json: string): Context_2;
417
+ static contextToJson(value: Context_2): string;
418
+ static toCountry(json: string): Country_2;
419
+ static countryToJson(value: Country_2): string;
420
+ static toCurrency(json: string): Currency;
421
+ static currencyToJson(value: Currency): string;
422
+ static toEmail(json: string): Email;
423
+ static emailToJson(value: Email): string;
424
+ static toInstrument(json: string): Instrument_2;
425
+ static instrumentToJson(value: Instrument_2): string;
426
+ static toInstrumentList(json: string): InstrumentList_2;
427
+ static instrumentListToJson(value: InstrumentList_2): string;
428
+ static toNothing(json: string): Nothing;
429
+ static nothingToJson(value: Nothing): string;
430
+ static toOrganization(json: string): Organization_2;
431
+ static organizationToJson(value: Organization_2): string;
432
+ static toPortfolio(json: string): Portfolio_2;
433
+ static portfolioToJson(value: Portfolio_2): string;
434
+ static toPosition(json: string): Position_2;
435
+ static positionToJson(value: Position_2): string;
436
+ static toTimeRange(json: string): TimeRange;
437
+ static timeRangeToJson(value: TimeRange): string;
438
+ static toValuation(json: string): Valuation;
439
+ static valuationToJson(value: Valuation): string;
440
+ }
441
+
442
+ declare interface Country {
443
+ id: CountryID;
444
+ type: string;
445
+ name?: string;
446
+ }
447
+
448
+ declare interface Country_2 {
449
+ id: CountryID_2;
450
+ type: string;
451
+ name?: string;
452
+ [property: string]: any;
453
+ }
454
+
455
+ declare interface CountryID {
456
+ ISOALPHA2?: string;
457
+ ISOALPHA3?: string;
458
+ }
459
+
460
+ declare interface CountryID_2 {
461
+ COUNTRY_ISOALPHA2?: string;
462
+ COUNTRY_ISOALPHA3?: string;
463
+ ISOALPHA2?: string;
464
+ ISOALPHA3?: string;
465
+ [property: string]: any;
466
+ }
467
+
468
+ declare interface Currency {
469
+ id: CurrencyID;
470
+ name?: string;
471
+ type: string;
472
+ [property: string]: any;
473
+ }
474
+
475
+ declare interface CurrencyID {
476
+ CURRENCY_ISOCODE?: string;
477
+ [property: string]: any;
478
+ }
479
+
480
+ /**
481
+ * A Desktop Agent is a desktop component (or aggregate of components) that serves as a
482
+ * launcher and message router (broker) for applications in its domain.
483
+ *
484
+ * A Desktop Agent can be connected to one or more App Directories and will use directories for application
485
+ * identity and discovery. Typically, a Desktop Agent will contain the proprietary logic of
486
+ * a given platform, handling functionality like explicit application interop workflows where
487
+ * security, consistency, and implementation requirements are proprietary.
488
+ */
489
+ declare interface DesktopAgent {
490
+ /**
491
+ * Launches an app by target, which can be optionally a string like a name, or an AppMetadata object.
492
+ *
493
+ * If a Context object is passed in, this object will be provided to the opened application via a contextListener.
494
+ * The Context argument is functionally equivalent to opening the target app with no context and broadcasting the context directly to it.
495
+ *
496
+ * If opening errors, it returns an `Error` with a string from the `OpenError` enumeration.
497
+ *
498
+ * ```javascript
499
+ * //no context and string as target
500
+ * agent.open('myApp');
501
+ * //no context and AppMetadata object as target
502
+ * agent.open({name: 'myApp', title: 'The title for the application myApp.', description: '...'});
503
+ * //with context
504
+ * agent.open('myApp', context);
505
+ * ```
506
+ */
507
+ open(app: TargetApp, context?: Context): Promise<void>;
508
+ /**
509
+ * Find out more information about a particular intent by passing its name, and optionally its context.
510
+ *
511
+ * findIntent is effectively granting programmatic access to the Desktop Agent's resolver.
512
+ * A promise resolving to the intent, its metadata and metadata about the apps that registered it is returned.
513
+ * This can be used to raise the intent against a specific app.
514
+ *
515
+ * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration.
516
+ *
517
+ * ```javascript
518
+ * // I know 'StartChat' exists as a concept, and want to know more about it ...
519
+ * const appIntent = await agent.findIntent("StartChat");
520
+ *
521
+ * // returns a single AppIntent:
522
+ * // {
523
+ * // intent: { name: "StartChat", displayName: "Chat" },
524
+ * // apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
525
+ * // }
526
+ *
527
+ * // raise the intent against a particular app
528
+ * await agent.raiseIntent(appIntent.intent.name, context, appIntent.apps[0].name);
529
+ * ```
530
+ */
531
+ findIntent(intent: string, context?: Context): Promise<AppIntent>;
532
+ /**
533
+ * Find all the avalable intents for a particular context.
534
+ *
535
+ * findIntents is effectively granting programmatic access to the Desktop Agent's resolver.
536
+ * A promise resolving to all the intents, their metadata and metadata about the apps that registered it is returned,
537
+ * based on the context types the intents have registered.
538
+ *
539
+ * If the resolution fails, the promise will return an `Error` with a string from the `ResolveError` enumeration.
540
+ *
541
+ * ```javascript
542
+ * // I have a context object, and I want to know what I can do with it, hence, I look for for intents...
543
+ * const appIntents = await agent.findIntentsByContext(context);
544
+ *
545
+ * // returns for example:
546
+ * // [{
547
+ * // intent: { name: "StartCall", displayName: "Call" },
548
+ * // apps: [{ name: "Skype" }]
549
+ * // },
550
+ * // {
551
+ * // intent: { name: "StartChat", displayName: "Chat" },
552
+ * // apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
553
+ * // }];
554
+ *
555
+ * // select a particular intent to raise
556
+ * const startChat = appIntents[1];
557
+ *
558
+ * // target a particular app
559
+ * const selectedApp = startChat.apps[0];
560
+ *
561
+ * // raise the intent, passing the given context, targeting the app
562
+ * await agent.raiseIntent(startChat.intent.name, context, selectedApp.name);
563
+ * ```
564
+ */
565
+ findIntentsByContext(context: Context): Promise<Array<AppIntent>>;
566
+ /**
567
+ * Publishes context to other apps on the desktop.
568
+ *
569
+ * DesktopAgent implementations should ensure that context messages broadcast to a channel
570
+ * by an application joined to it should not be delivered back to that same application.
571
+ *
572
+ * ```javascript
573
+ * agent.broadcast(context);
574
+ * ```
575
+ */
576
+ broadcast(context: Context): void;
577
+ /**
578
+ * Raises an intent to the desktop agent to resolve.
579
+ * ```javascript
580
+ * //Find apps to resolve an intent to start a chat with a given contact
581
+ * const appIntent = await fdc3.findIntent("StartChat", context);
582
+ * //use the returned AppIntent object to target one of the returned chat apps with the context
583
+ * await fdc3.raiseIntent("StartChat", context, appIntent.apps[0].name);
584
+ * //or use one of the AppMetadata objects returned in the AppIntent object's 'apps' array
585
+ * await fdc3.raiseIntent("StartChat", context, appMetadata);
586
+ * ```
587
+ */
588
+ raiseIntent(intent: string, context: Context, app?: TargetApp): Promise<IntentResolution>;
589
+ /**
590
+ * Raises a context to the desktop agent to resolve with one of the possible Intents for that context.
591
+ * ```javascript
592
+ * await fdc3.raiseIntentForContext(context);
593
+ * ```
594
+ */
595
+ raiseIntentForContext(context: Context, app?: TargetApp): Promise<IntentResolution>;
596
+ /**
597
+ * Adds a listener for incoming Intents from the Agent.
598
+ */
599
+ addIntentListener(intent: string, handler: ContextHandler): Listener;
600
+ /**
601
+ * Adds a listener for incoming context broadcast from the Desktop Agent.
602
+ * @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`.
603
+ */
604
+ addContextListener(handler: ContextHandler): Listener;
605
+ /**
606
+ * Adds a listener for the broadcast of a specific type of context object.
607
+ */
608
+ addContextListener(contextType: string | null, handler: ContextHandler): Listener;
609
+ /**
610
+ * Retrieves a list of the System channels available for the app to join
611
+ */
612
+ getSystemChannels(): Promise<Array<Channel>>;
613
+ /**
614
+ * Joins the app to the specified channel.
615
+ * An app can only be joined to one channel at a time.
616
+ * Rejects with error if the channel is unavailable or the join request is denied.
617
+ * `Error` with a string from the `ChannelError` enumeration.
618
+ */
619
+ joinChannel(channelId: string): Promise<void>;
620
+ /**
621
+ * Returns a channel with the given identity. Either stands up a new channel or returns an existing channel.
622
+ *
623
+ * It is up to applications to manage how to share knowledge of these custom channels across windows and to manage
624
+ * channel ownership and lifecycle.
625
+ *
626
+ * `Error` with a string from the `ChannelError` enumeration.
627
+ */
628
+ getOrCreateChannel(channelId: string): Promise<Channel>;
629
+ /**
630
+ * Returns the `Channel` object for the current channel membership.
631
+ *
632
+ * Returns `null` if the app is not joined to a channel.
633
+ */
634
+ getCurrentChannel(): Promise<Channel | null>;
635
+ /**
636
+ * Removes the app from any channel membership.
637
+ *
638
+ * Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be
639
+ * in a no-op when the app is not on a channel.
640
+ */
641
+ leaveCurrentChannel(): Promise<void>;
642
+ /**
643
+ * Retrieves information about the FDC3 Desktop Agent implementation, such as
644
+ * the implemented version of the FDC3 specification and the name of the implementation
645
+ * provider.
646
+ */
647
+ getInfo(): ImplementationMetadata;
648
+ }
649
+
650
+ /**
651
+ * A Desktop Agent is a desktop component (or aggregate of components) that serves as a
652
+ * launcher and message router (broker) for applications in its domain.
653
+ *
654
+ * A Desktop Agent can be connected to one or more App Directories and will use directories for application
655
+ * identity and discovery. Typically, a Desktop Agent will contain the proprietary logic of
656
+ * a given platform, handling functionality like explicit application interop workflows where
657
+ * security, consistency, and implementation requirements are proprietary.
658
+ */
659
+ declare interface DesktopAgent_2 {
660
+ /**
661
+ * Launches an app, specified via an `AppIdentifier` object.
662
+ *
663
+ * The `open` method differs in use from `raiseIntent`. Generally, it should be used when the target application is known but there is no specific intent. For example, if an application is querying the App Directory, `open` would be used to open an app returned in the search results.
664
+ *
665
+ * **Note**, if the intent, context and target app name are all known, it is recommended to instead use `raiseIntent` with the `target` argument.
666
+ *
667
+ * If a Context object is passed in, this object will be provided to the opened application via a contextListener. The Context argument is functionally equivalent to opening the target app with no context and broadcasting the context directly to it.
668
+ *
669
+ * Returns an `AppIdentifier` object with the `instanceId` field set identifying the instance of the application opened by this call.
670
+ *
671
+ * If an error occurs while opening the app, the promise MUST be rejected with an `Error` Object with a `message` chosen from the `OpenError` enumeration.
672
+ *
673
+ * ```javascript
674
+ * //Open an app without context, using an AppIdentifier object to specify the target by `appId`.
675
+ * let appIdentifier = {appId: 'myApp-v1.0.1'};
676
+ * let instanceIdentifier = await fdc3.open(appIdentifier);
677
+ *
678
+ * //Open an app with context
679
+ * let instanceIdentifier = await fdc3.open(appIdentifier, context);
680
+ * ```
681
+ */
682
+ open(app: AppIdentifier, context?: Context_2): Promise<AppIdentifier>;
683
+ /**
684
+ * Find out more information about a particular intent by passing its name, and optionally its context and/or a desired result context type.
685
+ *
686
+ * `findIntent` is effectively granting programmatic access to the Desktop Agent's resolver.
687
+ * It returns a promise resolving to the intent, its metadata and metadata about the apps and app instances that registered that intent.
688
+ * This can be used to raise the intent against a specific app or app instance.
689
+ *
690
+ * If the resolution fails, the promise MUST be rejected with an `Error` Object with a `message` chosen from the `ResolveError` enumeration. This includes the case where no apps are found that resolve the intent, when the `ResolveError.NoAppsFound` message should be used, and when an invalid context object is passed as an argument, when the `ResolveError.MalformedContext` message should be used.
691
+ *
692
+ * Result types may be a type name, the string "channel" (which indicates that the app
693
+ * will return a channel) or a string indicating a channel that returns a specific type,
694
+ * e.g. "channel<fdc3.instrument>".
695
+ *
696
+ * If intent resolution to an app returning a channel is requested, the desktop agent
697
+ * MUST include both apps that are registered as returning a channel and those registered
698
+ * as returning a channel with a specific type in the response.
699
+ *
700
+ * ```javascript
701
+ * // I know 'StartChat' exists as a concept, and want to know which apps can resolve it ...
702
+ * const appIntent = await fdc3.findIntent("StartChat");
703
+ *
704
+ * // returns a single AppIntent:
705
+ * // {
706
+ * // intent: { name: "StartChat" },
707
+ * // apps: [
708
+ * // { appId: "Skype" },
709
+ * // { appId: "Symphony" },
710
+ * // { appId: "Slack" }
711
+ * // ]
712
+ * // }
713
+ *
714
+ * // raise the intent against a particular app
715
+ * await fdc3.raiseIntent(appIntent.intent.name, context, appIntent.apps[0]);
716
+ *
717
+ * //later, we want to raise 'StartChat' intent again
718
+ * const appIntent = await fdc3.findIntent("StartChat");
719
+ * // returns an AppIntent, but with multiple options for resolution,
720
+ * // which includes an existing instance of an application:
721
+ * // {
722
+ * // intent: { name: "StartChat" },
723
+ * // apps: [
724
+ * // { appId: "Skype" },
725
+ * // { appId: "Symphony" },
726
+ * // { appId: "Symphony", instanceId: "93d2fe3e-a66c-41e1-b80b-246b87120859" },
727
+ * // { appId: "Slack" }
728
+ * // ]
729
+ * ```
730
+ *
731
+ * An optional input context object and result type may be specified, which the resolver MUST use to filter the returned applications such that each supports the specified input and result types.
732
+ *
733
+ * ```javascript
734
+ * const appIntent = await fdc3.findIntent("StartChat", contact);
735
+ *
736
+ * // returns only apps that support the type of the specified input context:
737
+ * // {
738
+ * // intent: { name: "StartChat" },
739
+ * // apps: [{ appId: "Symphony" }]
740
+ * // }
741
+ *
742
+ * const appIntent = await fdc3.findIntent("ViewContact", contact, "fdc3.ContactList");
743
+ *
744
+ * // returns only apps that return the specified result Context type:
745
+ * // {
746
+ * // intent: { name: "ViewContact" },
747
+ * // apps: { appId: "MyCRM", resultType: "fdc3.ContactList"}]
748
+ * // }
749
+ *
750
+ * const appIntent = await fdc3.findIntent("QuoteStream", instrument, "channel<fdc3.Quote>");
751
+ *
752
+ * // returns only apps that return a channel which will receive the specified input and result types:
753
+ * // {
754
+ * // intent: { name: "QuoteStream" },
755
+ * // apps: [{ appId: "MyOMS", resultType: "channel<fdc3.Quote>"}]
756
+ * // }
757
+ * ```
758
+ */
759
+ findIntent(intent: string, context?: Context_2, resultType?: string): Promise<AppIntent_2>;
760
+ /**
761
+ * Find all the available intents for a particular context, and optionally a desired result context type.
762
+ *
763
+ * `findIntentsByContext` is effectively granting programmatic access to the Desktop Agent's resolver.
764
+ * It returns a promise resolving to an `AppIntent` which provides details of the intent, its metadata and metadata about the apps and app instances that are registered to handle it. This can be used to raise the intent against a specific app or app instance.
765
+ *
766
+ * If the resolution fails, the promise MUST be rejected with an `Error` Object with a `message` chosen from the `ResolveError` enumeration. This includes the case where no intents with associated apps are found, when the `ResolveError.NoAppsFound` message should be used, and when an invalid context object is passed as an argument, when the `ResolveError.MalformedContext` message should be used.
767
+ *
768
+ * The optional `resultType` argument may be a type name, the string "channel" (which indicates that the app
769
+ * should return a channel) or a string indicating a channel that returns a specific type,
770
+ * e.g. "channel<fdc3.instrument>". If intent resolution to an app returning a channel is requested without
771
+ * a specified context type, the desktop agent MUST also include apps that are registered as returning a
772
+ * channel with a specific type in the response.
773
+ *
774
+ * ```javascript
775
+ * // I have a context object, and I want to know what I can do with it, hence, I look for intents and apps to resolve them...
776
+ * const appIntents = await fdc3.findIntentsByContext(context);
777
+ *
778
+ * // returns for example:
779
+ * // [
780
+ * // {
781
+ * // intent: { name: "StartCall" },
782
+ * // apps: [{ name: "Skype" }]
783
+ * // },
784
+ * // {
785
+ * // intent: { name: "StartChat" },
786
+ * // apps: [
787
+ * // { appId: "Skype" },
788
+ * // { appId: "Symphony" },
789
+ * // { appId: "Symphony", instanceId: "93d2fe3e-a66c-41e1-b80b-246b87120859" },
790
+ * // { appId: "Slack" }
791
+ * // ]
792
+ * // }
793
+ * // ];
794
+ *
795
+ * // or I look for only intents that are resolved by apps returning a particular result type
796
+ * const appIntentsForType = await fdc3.findIntentsByContext(context, "fdc3.ContactList");
797
+ * // returns for example:
798
+ * // [{
799
+ * // intent: { name: "ViewContact" },
800
+ * // apps: [{ appId: "MyCRM", resultType: "fdc3.ContactList"}]
801
+ * // }];
802
+ *
803
+ * // select a particular intent to raise
804
+ * const resolvedIntent = appIntents[1];
805
+ *
806
+ * // target a particular app or instance
807
+ * const selectedApp = resolvedIntent.apps[2];
808
+ *
809
+ * // raise the intent, passing the given context, targeting the app or app instance
810
+ * await fdc3.raiseIntent(startChat.intent.name, context, selectedApp);
811
+ * ```
812
+ */
813
+ findIntentsByContext(context: Context_2, resultType?: string): Promise<Array<AppIntent_2>>;
814
+ /**
815
+ * Find all the available instances for a particular application.
816
+ *
817
+ * If there are no instances of the specified application the returned promise should resolve to an empty array.
818
+ *
819
+ * If the request fails for another reason, the promise MUST be rejected with an `Error` Object with a `message` chosen from the `ResolveError` enumeration.
820
+ *
821
+ * ```javascript
822
+ * // Retrieve a list of instances of an application
823
+ * let instances = await fdc3.findInstances({appId: "MyAppId"});
824
+ *
825
+ * // Target a raised intent at a specific instance
826
+ * let resolution = fdc3.raiseIntent("ViewInstrument", context, instances[0]);
827
+ * ```
828
+ * @param app
829
+ */
830
+ findInstances(app: AppIdentifier): Promise<Array<AppIdentifier>>;
831
+ /**
832
+ * Publishes context to other apps on the desktop. Calling `broadcast` at the `DesktopAgent` scope will push the context to whatever _User Channel_ the app is joined to. If the app is not currently joined to a channel, calling `fdc3.broadcast` will have no effect. Apps can still directly broadcast and listen to context on any channel via the methods on the `Channel` class.
833
+ *
834
+ * DesktopAgent implementations should ensure that context messages broadcast to a channel by an application joined to it should not be delivered back to that same application.
835
+ *
836
+ * If you are working with complex context types composed of other simpler types then you should broadcast
837
+ * each individual type (starting with the simpler types, followed by the complex type) that you want other
838
+ * apps to be able to respond to. Doing so allows applications to filter the context types they receive by
839
+ * adding listeners for specific context types.
840
+ *
841
+ * If an application attempts to broadcast an invalid context argument the Promise returned by this function should reject with the `ChannelError.MalformedContext` error.
842
+ *
843
+ * ```javascript
844
+ * const instrument = {
845
+ * type: 'fdc3.instrument',
846
+ * id: {
847
+ * ticker: 'AAPL'
848
+ * }
849
+ * };
850
+ * fdc3.broadcast(context);
851
+ * ```
852
+ */
853
+ broadcast(context: Context_2): Promise<void>;
854
+ /**
855
+ * Raises a specific intent for resolution against apps registered with the desktop agent.
856
+ *
857
+ * The desktop agent MUST resolve the correct app to target based on the provided intent name and context data. If multiple matching apps are found, the user MAY be presented with a Resolver UI allowing them to pick one, or another method of Resolution applied to select an app.
858
+ * Alternatively, the specific app or app instance to target can also be provided. A list of valid target applications and instances can be retrieved via `findIntent`.
859
+ *
860
+ * If a target app for the intent cannot be found with the criteria provided or the user either closes the resolver UI or otherwise cancels resolution, the promise MUST be rejected with an `Error` object with a `message` chosen from the `ResolveError` enumeration. If a specific target `app` parameter was set, but either the app or app instance is not available, the promise MUST be rejected with an `Error` object with either the `ResolveError.TargetAppUnavailable` or `ResolveError.TargetInstanceUnavailable` string as its `message`. If an invalid context object is passed as an argument the promise MUST be rejected with an `Error` object with the `ResolveError.MalformedContext` string as its `message`.
861
+ *
862
+ * If you wish to raise an Intent without a context, use the `fdc3.nothing` context type. This type exists so that apps can explicitly declare support for raising an intent without context.
863
+ *
864
+ * Returns an `IntentResolution` object with details of the app instance that was selected (or started) to respond to the intent.
865
+ *
866
+ * Issuing apps may optionally wait on the promise that is returned by the `getResult()` member of the `IntentResolution`. This promise will resolve when the _receiving app's_ intent handler function returns and resolves a promise. The Desktop Agent resolves the issuing app's promise with the Context object, Channel object or void that is provided as resolution within the receiving app. The Desktop Agent MUST reject the issuing app's promise, with a string from the `ResultError` enumeration, if: (1) the intent handling function's returned promise rejects, (2) the intent handling function doesn't return a valid response (a promise or void), or (3) the returned promise resolves to an invalid type.
867
+ *
868
+ * ```javascript
869
+ * // raise an intent for resolution by the desktop agent
870
+ * // a resolver UI may be displayed if more than one application can resolve the intent
871
+ * await fdc3.raiseIntent("StartChat", context);
872
+ *
873
+ * // or find apps to resolve an intent to start a chat with a given contact
874
+ * const appIntent = await fdc3.findIntent("StartChat", context);
875
+
876
+ * // use the metadata of an app or app instance to describe the target app for the intent
877
+ * await fdc3.raiseIntent("StartChat", context, appIntent.apps[0]);
878
+ *
879
+ * //Raise an intent without a context by using the null context type
880
+ * await fdc3.raiseIntent("StartChat", {type: "fdc3.nothing"});
881
+ *
882
+ * //Raise an intent and retrieve a result from the IntentResolution
883
+ * let resolution = await agent.raiseIntent("intentName", context);
884
+ * try {
885
+ * const result = await resolution.getResult();
886
+ * if (result && result.broadcast) { //detect whether the result is Context or a Channel
887
+ * console.log(`${resolution.source} returned a channel with id ${result.id}`);
888
+ * } else if (result){
889
+ * console.log(`${resolution.source} returned data: ${JSON.stringify(result)}`);
890
+ * } else {
891
+ * console.error(`${resolution.source} didn't return anything`
892
+ * }
893
+ * } catch(error) {
894
+ * console.error(`${resolution.source} returned an error: ${error}`);
895
+ * }
896
+ * ```
897
+ */
898
+ raiseIntent(intent: string, context: Context_2, app?: AppIdentifier): Promise<IntentResolution_2>;
899
+ /**
900
+ * Finds and raises an intent against apps registered with the desktop agent based on the type of the specified context data example.
901
+ *
902
+ * The desktop agent SHOULD first resolve to a specific intent based on the provided context if more than one intent is available for the specified context. This MAY be achieved by displaying a resolver UI. It SHOULD then resolve to a specific app to handle the selected intent and specified context.
903
+ * Alternatively, the specific app or app instance to target can also be provided, in which case the resolver SHOULD only offer intents supported by the specified application.
904
+ *
905
+ * Using `raiseIntentForContext` is similar to calling `findIntentsByContext`, and then raising an intent against one of the returned apps, except in this case the desktop agent has the opportunity to provide the user with a richer selection interface where they can choose both the intent and target app.
906
+ *
907
+ * Returns an `IntentResolution` object, see `raiseIntent()` for details.
908
+ *
909
+ * If a target intent and app cannot be found with the criteria provided or the user either closes the resolver UI or otherwise cancels resolution, the promise MUST be rejected with an `Error` object with a `message` chosen from the `ResolveError` enumeration. If a specific target `app` parameter was set, but either the app or app instance is not available, the promise MUST be rejected with an `Error` object with either the `ResolveError.TargetAppUnavailable` or `ResolveError.TargetInstanceUnavailable` string as its `message`. If an invalid context object is passed as an argument the promise MUST be rejected with an `Error` object with the `ResolveError.MalformedContext` string as its `message`.
910
+ *
911
+ * ```javascript
912
+ * // Resolve against all intents registered for the type of the specified context
913
+ * await fdc3.raiseIntentForContext(context);
914
+ *
915
+ * // Resolve against all intents registered by a specific target app for the specified context
916
+ * await fdc3.raiseIntentForContext(context, targetAppIdentifier);
917
+ * ```
918
+ */
919
+ raiseIntentForContext(context: Context_2, app?: AppIdentifier): Promise<IntentResolution_2>;
920
+ /**
921
+ * Adds a listener for incoming intents from the Desktop Agent. The handler function may return void or a promise that resolves to an `IntentResult`, which is either a `Context` object, representing any data that should be returned to the app that raised the intent, a `Channel` Object, a `PrivateChannel` over which data responses will be sent, or `void`. The `IntentResult` will be returned to the app that raised the intent via the `IntentResolution` and retrieved from it using the `getResult()` function.
922
+ *
923
+ * The Desktop Agent MUST reject the promise returned by the `getResult()` function of `IntentResolution` if: (1) the intent handling function's returned promise rejects, (2) the intent handling function doesn't return a promise, or (3) the returned promise resolves to an invalid type.
924
+ *
925
+ * The `PrivateChannel` type is provided to support synchronization of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via raising an intent.
926
+ *
927
+ * Optional metadata about the raised intent, including the app that originated the message, SHOULD be provided by the desktop agent implementation.
928
+ *
929
+ * ```javascript
930
+ * //Handle a raised intent
931
+ * const listener = fdc3.addIntentListener('StartChat', context => {
932
+ * // start chat has been requested by another application
933
+ * return;
934
+ * });
935
+ *
936
+ * //Handle a raised intent and log the originating app metadata
937
+ * const listener = fdc3.addIntentListener('StartChat', (contact, metadata) => {
938
+ * console.log(`Received intent StartChat\nContext: ${contact}\nOriginating app: ${metadata?.source}`);
939
+ * return;
940
+ * });
941
+ *
942
+ * //Handle a raised intent and return Context data via a promise
943
+ * fdc3.addIntentListener("CreateOrder", (context) => {
944
+ * return new Promise<Context>((resolve) => {
945
+ * // go create the order
946
+ * resolve({type: "fdc3.order", id: { "orderId": 1234}});
947
+ * });
948
+ * });
949
+ *
950
+ * //Handle a raised intent and return a Private Channel over which response will be sent
951
+ * fdc3.addIntentListener("QuoteStream", async (context) => {
952
+ * const channel: PrivateChannel = await fdc3.createPrivateChannel();
953
+ * const symbol = context.id.symbol;
954
+ *
955
+ * // Called when the remote side adds a context listener
956
+ * const addContextListener = channel.onAddContextListener((contextType) => {
957
+ * // broadcast price quotes as they come in from our quote feed
958
+ * feed.onQuote(symbol, (price) => {
959
+ * channel.broadcast({ type: "price", price});
960
+ * });
961
+ * });
962
+ *
963
+ * // Stop the feed if the remote side closes
964
+ * const disconnectListener = channel.onDisconnect(() => {
965
+ * feed.stop(symbol);
966
+ * });
967
+ *
968
+ * return channel;
969
+ * });
970
+ * ```
971
+ */
972
+ addIntentListener(intent: string, handler: IntentHandler): Promise<Listener_2>;
973
+ /**
974
+ * Adds a listener for incoming context broadcasts from the Desktop Agent via User channels. If the consumer is only interested in a context of a particular type, they can they can specify that type. If the consumer is able to receive context of any type or will inspect types received, then they can pass `null` as the `contextType` parameter to receive all context types.
975
+ *
976
+ * Context broadcasts are only received from apps that are joined to the same User channel as the listening application, hence, if the application is not currently joined to a channel no broadcasts will be received. If this function is called after the app has already joined a channel and the channel already contains context that would be passed to the context listener, then it will be called immediately with that context.
977
+ *
978
+ * Optional metadata about the context message, including the app that originated the message, SHOULD be provided by the desktop agent implementation.
979
+ *
980
+ * ```javascript
981
+ * // any context
982
+ * const listener = await fdc3.addContextListener(null, context => { ... });
983
+ *
984
+ * // listener for a specific type
985
+ * const contactListener = await fdc3.addContextListener('fdc3.contact', contact => { ... });
986
+ *
987
+ * // listener that logs metadata for the message a specific type
988
+ * const contactListener = await fdc3.addContextListener('fdc3.contact', (contact, metadata) => {
989
+ * console.log(`Received context message\nContext: ${contact}\nOriginating app: ${metadata?.source}`);
990
+ * //do something else with the context
991
+ * });
992
+ * ```
993
+ */
994
+ addContextListener(contextType: string | null, handler: ContextHandler_2): Promise<Listener_2>;
995
+ /**
996
+ * Retrieves a list of the User channels available for the app to join.
997
+ */
998
+ getUserChannels(): Promise<Array<Channel_2>>;
999
+ /**
1000
+ * Optional function that joins the app to the specified User channel. In most cases, applications SHOULD be joined to channels via UX provided to the application by the desktop agent, rather than calling this function directly.
1001
+ *
1002
+ * If an app is joined to a channel, all `fdc3.broadcast` calls will go to the channel, and all listeners assigned via `fdc3.addContextListener` will listen on the channel.
1003
+ *
1004
+ * If the channel already contains context that would be passed to context listeners assed via `fdc3.addContextListener` then those listeners will be called immediately with that context.
1005
+ *
1006
+ * An app can only be joined to one channel at a time.
1007
+ *
1008
+ * If an error occurs (such as the channel is unavailable or the join request is denied) the promise MUST be rejected with an `Error` Object with a `message` chosen from the `ChannelError` enumeration.
1009
+ *
1010
+ * ```javascript
1011
+ * // get all system channels
1012
+ * const channels = await fdc3.getUserChannels();
1013
+ * // create UI to pick from the User channels
1014
+ * // join the channel on selection
1015
+ * fdc3.joinUserChannel(selectedChannel.id);
1016
+ * ```
1017
+ */
1018
+ joinUserChannel(channelId: string): Promise<void>;
1019
+ /**
1020
+ * Returns a `Channel` object for the specified channel, creating it (as an _App_ channel) if it does not exist.
1021
+ *
1022
+ * If the Channel cannot be created or access was denied, the returned promise MUST be rejected with an `Error` Object with a `message` chosen from the `ChannelError` enumeration.
1023
+ *
1024
+ * ```javascript
1025
+ * try {
1026
+ * const myChannel = await fdc3.getOrCreateChannel("myChannel");
1027
+ * const myChannel.addContextListener(null, context => {});
1028
+ * }
1029
+ * catch (err){
1030
+ * //app could not register the channel
1031
+ * }
1032
+ * ```
1033
+ */
1034
+ getOrCreateChannel(channelId: string): Promise<Channel_2>;
1035
+ /**
1036
+ * Returns a `Channel` with an auto-generated identity that is intended for private communication between applications. Primarily used to create Channels that will be returned to other applications via an `IntentResolution` for a raised intent.
1037
+ *
1038
+ * If the `PrivateChannel` cannot be created, the returned promise MUST be rejected with an `Error` object with a `message` chosen from the `ChannelError` enumeration.
1039
+ *
1040
+ * The `PrivateChannel` type is provided to support synchronisation of data transmitted over returned channels, by allowing both parties to listen for events denoting subscription and unsubscription from the returned channel. `PrivateChannels` are only retrievable via raising an intent.
1041
+ *
1042
+ * * It is intended that Desktop Agent implementations:
1043
+ * - SHOULD restrict external apps from listening or publishing on this channel.
1044
+ * - MUST prevent `PrivateChannels` from being retrieved via fdc3.getOrCreateChannel.
1045
+ * - MUST provide the `id` value for the channel as required by the `Channel` interface.
1046
+ *
1047
+ * ```javascript
1048
+ * fdc3.addIntentListener("QuoteStream", async (context) => {
1049
+ * const channel: PrivateChannel = await fdc3.createPrivateChannel();
1050
+ * const symbol = context.id.ticker;
1051
+ *
1052
+ * // This gets called when the remote side adds a context listener
1053
+ * const addContextListener = channel.onAddContextListener((contextType) => {
1054
+ * // broadcast price quotes as they come in from our quote feed
1055
+ * feed.onQuote(symbol, (price) => {
1056
+ * channel.broadcast({ type: "price", price});
1057
+ * });
1058
+ * });
1059
+ *
1060
+ * // This gets called when the remote side calls Listener.unsubscribe()
1061
+ * const unsubscriberListener = channel.onUnsubscribe((contextType) => {
1062
+ * feed.stop(symbol);
1063
+ * });
1064
+ *
1065
+ * // This gets called if the remote side closes
1066
+ * const disconnectListener = channel.onDisconnect(() => {
1067
+ * feed.stop(symbol);
1068
+ * })
1069
+ *
1070
+ * return channel;
1071
+ * });
1072
+ * ```
1073
+ */
1074
+ createPrivateChannel(): Promise<PrivateChannel>;
1075
+ /**
1076
+ * Optional function that returns the `Channel` object for the current User channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.
1077
+ *
1078
+ * Returns `null` if the app is not joined to a channel.
1079
+ */
1080
+ getCurrentChannel(): Promise<Channel_2 | null>;
1081
+ /**
1082
+ * Optional function that removes the app from any User channel membership. In most cases, an application's membership of channels SHOULD be managed via UX provided to the application by the desktop agent, rather than calling this function directly.
1083
+ *
1084
+ * Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be a no-op when the app is not on a channel.
1085
+ *
1086
+ * ```javascript
1087
+ * //desktop-agent scope context listener
1088
+ * const fdc3Listener = fdc3.addContextListener(null, context => {});
1089
+ * await fdc3.leaveCurrentChannel();
1090
+ * //the fdc3Listener will now cease receiving context
1091
+ * //listening on a specific channel, retrieved via fdc3.getOrCreateChannel(), will continue to work:
1092
+ * redChannel.addContextListener(null, channelListener);
1093
+ * ```
1094
+ */
1095
+ leaveCurrentChannel(): Promise<void>;
1096
+ /**
1097
+ * Retrieves information about the FDC3 Desktop Agent implementation, including the supported version
1098
+ * of the FDC3 specification, the name of the provider of the implementation, its own version number
1099
+ * and the metadata of the calling application according to the desktop agent.
1100
+ *
1101
+ * Returns an `ImplementationMetadata` object. This metadata object can be used to vary the behavior
1102
+ * of an application based on the version supported by the Desktop Agent and for logging purposes.
1103
+ *
1104
+ * ```js
1105
+ * import {compareVersionNumbers, versionIsAtLeast} from '@finos/fdc3';
1106
+ *
1107
+ * if (fdc3.getInfo && versionIsAtLeast(await fdc3.getInfo(), "1.2")) {
1108
+ * await fdc3.raiseIntentForContext(context);
1109
+ * } else {
1110
+ * await fdc3.raiseIntent("ViewChart", context);
1111
+ * }
1112
+ * ```
1113
+ *
1114
+ * The `ImplementationMetadata` object returned also includes the metadata for the calling application,
1115
+ * according to the Desktop Agent. This allows the application to retrieve its own `appId`, `instanceId`
1116
+ * and other details, e.g.:
1117
+ *
1118
+ * ```js
1119
+ * let implementationMetadata = await fdc3.getInfo();
1120
+ * let {appId, instanceId} = implementationMetadata.appMetadata;
1121
+ * ```
1122
+ */
1123
+ getInfo(): Promise<ImplementationMetadata_2>;
1124
+ /**
1125
+ * Retrieves the `AppMetadata` for an `AppIdentifier`, which provides additional metadata (such as icons,
1126
+ * a title and description) from the App Directory record for the application, that may be used for display
1127
+ * purposes.
1128
+ *
1129
+ * ```js
1130
+ * let appIdentifier = { appId: "MyAppId@my.appd.com" }
1131
+ * let appMetadata = await fdc3.getAppMetadata(appIdentifier);
1132
+ * ```
1133
+ */
1134
+ getAppMetadata(app: AppIdentifier): Promise<AppMetadata_2>;
1135
+ /**
1136
+ * Adds a listener for incoming context broadcasts from the Desktop Agent.
1137
+ * @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`. Provided for backwards compatibility with versions FDC3 standard <2.0.
1138
+ */
1139
+ addContextListener(handler: ContextHandler_2): Promise<Listener_2>;
1140
+ /**
1141
+ * @deprecated Alias to the `getUserChannels` function provided for backwards compatibility with versions FDC3 standard <2.0.
1142
+ */
1143
+ getSystemChannels(): Promise<Array<Channel_2>>;
1144
+ /**
1145
+ * @deprecated Alias to the `joinUserChannel` function Provided for backwards compatibility with versions FDC3 standard <2.0.
1146
+ */
1147
+ joinChannel(channelId: string): Promise<void>;
1148
+ /**
1149
+ * @deprecated version of `open` that launches an app by by name rather than `AppIdentifier`. Provided for backwards compatibility with versions FDC3 standard <2.0.
1150
+ *
1151
+ * ```javascript
1152
+ * //Open an app without context, using the app name
1153
+ * let instanceMetadata = await fdc3.open('myApp');
1154
+ * ```
1155
+ */
1156
+ open(name: string, context?: Context_2): Promise<AppIdentifier>;
1157
+ /**
1158
+ * @deprecated version of `raiseIntent` that targets an app by by name rather than `AppIdentifier`. Provided for backwards compatibility with versions FDC3 standard <2.0.
1159
+ *
1160
+ * ```javascript
1161
+ * // use the `name` metadata of an app to describe the target app for the intent
1162
+ * await fdc3.raiseIntent("StartChat", context, appIntent.apps[0].name);
1163
+ * ```
1164
+ */
1165
+ raiseIntent(intent: string, context: Context_2, name: string): Promise<IntentResolution_2>;
1166
+ /**
1167
+ * @deprecated version of `raiseIntentForContext` that targets an app by by name rather than `AppIdentifier`. Provided for backwards compatibility with versions FDC3 standard <2.0.
1168
+ *
1169
+ * ```javascript
1170
+ * // Resolve against all intents registered by a specific target app name for the specified context
1171
+ * await fdc3.raiseIntentForContext(context, targetAppName);
1172
+ * ```
1173
+ */
1174
+ raiseIntentForContext(context: Context_2, name: string): Promise<IntentResolution_2>;
1175
+ }
1176
+
1177
+ /**
1178
+ * SPDX-License-Identifier: Apache-2.0
1179
+ * Copyright 2019 FINOS FDC3 contributors - see NOTICE file
1180
+ */
1181
+ /**
1182
+ * A system channel will be global enough to have a presence across many apps. This gives us some hints
1183
+ * to render them in a standard way. It is assumed it may have other properties too, but if it has these,
1184
+ * this is their meaning.
1185
+ */
1186
+ declare interface DisplayMetadata {
1187
+ /**
1188
+ * A user-readable name for this channel, e.g: `"Red"`
1189
+ */
1190
+ readonly name?: string;
1191
+ /**
1192
+ * The color that should be associated within this channel when displaying this channel in a UI, e.g: `0xFF0000`.
1193
+ */
1194
+ readonly color?: string;
1195
+ /**
1196
+ * A URL of an image that can be used to display this channel
1197
+ */
1198
+ readonly glyph?: string;
1199
+ }
1200
+
1201
+ /**
1202
+ * SPDX-License-Identifier: Apache-2.0
1203
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1204
+ */
1205
+ /**
1206
+ * A system channel will be global enough to have a presence across many apps. This gives us some hints
1207
+ * to render them in a standard way. It is assumed it may have other properties too, but if it has these,
1208
+ * this is their meaning.
1209
+ */
1210
+ declare interface DisplayMetadata_2 {
1211
+ /**
1212
+ * A user-readable name for this channel, e.g: `"Red"`
1213
+ */
1214
+ readonly name?: string;
1215
+ /**
1216
+ * The color that should be associated within this channel when displaying this channel in a UI, e.g: `0xFF0000`.
1217
+ */
1218
+ readonly color?: string;
1219
+ /**
1220
+ * A URL of an image that can be used to display this channel
1221
+ */
1222
+ readonly glyph?: string;
1223
+ }
1224
+
1225
+ declare interface Email {
1226
+ recipients: RecipientsObject;
1227
+ subject?: string;
1228
+ textBody?: string;
1229
+ type: string;
1230
+ id?: {
1231
+ [key: string]: any;
1232
+ };
1233
+ name?: string;
1234
+ [property: string]: any;
1235
+ }
1236
+
1237
+ declare interface FluffyID {
1238
+ email?: string;
1239
+ FDS_ID?: string;
1240
+ [property: string]: any;
1241
+ }
1242
+
1243
+ declare interface FluffyMarket {
1244
+ BBG?: string;
1245
+ COUNTRY_ISOALPHA2?: string;
1246
+ MIC?: string;
1247
+ name?: string;
1248
+ [property: string]: any;
1249
+ }
1250
+
1251
+ /**
1252
+ * SPDX-License-Identifier: Apache-2.0
1253
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1254
+ */
1255
+ declare interface Icon {
1256
+ /** The icon url */
1257
+ readonly src: string;
1258
+ /** The icon dimension, formatted as `<height>x<width>`. */
1259
+ readonly size?: string;
1260
+ /** Icon media type. If not present the Desktop Agent may use the src file extension. */
1261
+ readonly type?: string;
1262
+ }
1263
+
1264
+ /**
1265
+ * SPDX-License-Identifier: Apache-2.0
1266
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1267
+ */
1268
+ declare interface Image_2 {
1269
+ /** The image url. */
1270
+ readonly src: string;
1271
+ /** The image dimension, formatted as `<height>x<width>`. */
1272
+ readonly size?: string;
1273
+ /** Image media type. If not present the Desktop Agent may use the src file extension. */
1274
+ readonly type?: string;
1275
+ /** Caption for the image. */
1276
+ readonly label?: string;
1277
+ }
1278
+
1279
+ /**
1280
+ * SPDX-License-Identifier: Apache-2.0
1281
+ * Copyright 2021 FINOS FDC3 contributors - see NOTICE file
1282
+ */
1283
+ /**
1284
+ * Metadata relating to the FDC3 Desktop Agent implementation and its provider.
1285
+ */
1286
+ declare interface ImplementationMetadata {
1287
+ /** The version number of the FDC3 specification that the implementation provides.
1288
+ * The string must be a numeric semver version, e.g. 1.2 or 1.2.1.
1289
+ */
1290
+ readonly fdc3Version: string;
1291
+ /** The name of the provider of the FDC3 Desktop Agent Implementation (e.g. Finsemble, Glue42, OpenFin etc.). */
1292
+ readonly provider: string;
1293
+ /** The version of the provider of the FDC3 Desktop Agent Implementation (e.g. 5.3.0). */
1294
+ readonly providerVersion?: string;
1295
+ }
1296
+
1297
+ /**
1298
+ * Metadata relating to the FDC3 Desktop Agent implementation and its provider.
1299
+ */
1300
+ declare interface ImplementationMetadata_2 {
1301
+ /** The version number of the FDC3 specification that the implementation provides.
1302
+ * The string must be a numeric semver version, e.g. 1.2 or 1.2.1.
1303
+ */
1304
+ readonly fdc3Version: string;
1305
+ /** The name of the provider of the Desktop Agent implementation (e.g. Finsemble, Glue42, OpenFin etc.). */
1306
+ readonly provider: string;
1307
+ /** The version of the provider of the Desktop Agent implementation (e.g. 5.3.0). */
1308
+ readonly providerVersion?: string;
1309
+ /** Metadata indicating whether the Desktop Agent implements optional features of
1310
+ * the Desktop Agent API.
1311
+ */
1312
+ readonly optionalFeatures: {
1313
+ /** Used to indicate whether the exposure of 'originating app metadata' for
1314
+ * context and intent messages is supported by the Desktop Agent.*/
1315
+ readonly OriginatingAppMetadata: boolean;
1316
+ /** Used to indicate whether the optional `fdc3.joinUserChannel`,
1317
+ * `fdc3.getCurrentChannel` and `fdc3.leaveCurrentChannel` are implemented by
1318
+ * the Desktop Agent.*/
1319
+ readonly UserChannelMembershipAPIs: boolean;
1320
+ };
1321
+ /** The calling application instance's own metadata, according to the Desktop Agent (MUST include at least the `appId` and `instanceId`). */
1322
+ readonly appMetadata: AppMetadata_2;
1323
+ }
1324
+
1325
+ declare interface Instrument {
1326
+ id: InstrumentID;
1327
+ type: string;
1328
+ name?: string;
1329
+ }
1330
+
1331
+ declare interface Instrument_2 {
1332
+ id: StickyID;
1333
+ market?: FluffyMarket;
1334
+ type: string;
1335
+ name?: string;
1336
+ [property: string]: any;
1337
+ }
1338
+
1339
+ declare interface InstrumentElement {
1340
+ id: PurpleID;
1341
+ market?: PurpleMarket;
1342
+ type: string;
1343
+ name?: string;
1344
+ [property: string]: any;
1345
+ }
1346
+
1347
+ declare interface InstrumentID {
1348
+ BBG?: string;
1349
+ CUSIP?: string;
1350
+ FDS_ID?: string;
1351
+ FIGI?: string;
1352
+ ISIN?: string;
1353
+ PERMID?: string;
1354
+ RIC?: string;
1355
+ SEDOL?: string;
1356
+ ticker?: string;
1357
+ }
1358
+
1359
+ declare interface InstrumentList {
1360
+ instruments: Instrument[];
1361
+ type: string;
1362
+ id?: {
1363
+ [key: string]: string;
1364
+ };
1365
+ name?: string;
1366
+ }
1367
+
1368
+ declare interface InstrumentList_2 {
1369
+ instruments: InstrumentElement[];
1370
+ type: string;
1371
+ id?: {
1372
+ [key: string]: any;
1373
+ };
1374
+ name?: string;
1375
+ [property: string]: any;
1376
+ }
1377
+
1378
+ /**
1379
+ * Describes a callback that handles a context event and may return a
1380
+ * promise of a Context, Channel object or void to be returned to the
1381
+ * application that raised the intent.
1382
+ * Used when attaching listeners for raised intents.
1383
+ *
1384
+ * Optional metadata about the raised intent, including the app that originated
1385
+ * the message, SHOULD be provided by the desktop agent implementation.
1386
+ */
1387
+ declare type IntentHandler = (context: Context_2, metadata?: ContextMetadata) => Promise<IntentResult> | void;
1388
+
1389
+ /**
1390
+ * SPDX-License-Identifier: Apache-2.0
1391
+ * Copyright 2019 FINOS FDC3 contributors - see NOTICE file
1392
+ */
1393
+ /**
1394
+ * Intent descriptor
1395
+ */
1396
+ declare interface IntentMetadata {
1397
+ /** The unique name of the intent that can be invoked by the raiseIntent call */
1398
+ readonly name: string;
1399
+ /** A friendly display name for the intent that should be used to render UI elements */
1400
+ readonly displayName: string;
1401
+ }
1402
+
1403
+ /**
1404
+ * SPDX-License-Identifier: Apache-2.0
1405
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1406
+ */
1407
+ /**
1408
+ * Intent descriptor
1409
+ */
1410
+ declare interface IntentMetadata_2 {
1411
+ /** The unique name of the intent that can be invoked by the raiseIntent call */
1412
+ readonly name: string;
1413
+ /** Display name for the intent.
1414
+ * @deprecated Use the intent name for display as display name may vary for
1415
+ * each application as it is defined in the app's AppD record.
1416
+ */
1417
+ readonly displayName: string;
1418
+ }
1419
+
1420
+ /**
1421
+ * IntentResolution provides a standard format for data returned upon resolving an intent.
1422
+ * ```javascript
1423
+ * //resolve a "Chain" type intent
1424
+ * var intentR = await agent.raiseIntent("intentName", context);
1425
+ * //resolve a "Client-Service" type intent with data response
1426
+ * var intentR = await agent.raiseIntent("intentName", context);
1427
+ * var dataR = intentR.data;
1428
+ * ```
1429
+ */
1430
+ declare interface IntentResolution {
1431
+ readonly source: TargetApp;
1432
+ /**
1433
+ * @deprecated not assignable from intent listeners
1434
+ */
1435
+ readonly data?: object;
1436
+ readonly version: string;
1437
+ }
1438
+
1439
+ /**
1440
+ * IntentResolution provides a standard format for data returned upon resolving an intent.
1441
+ *
1442
+ * ```javascript
1443
+ * //resolve a "Chain" type intent
1444
+ * let resolution = await agent.raiseIntent("intentName", context);
1445
+ *
1446
+ * //resolve a "Client-Service" type intent with a data response or a Channel
1447
+ * let resolution = await agent.raiseIntent("intentName", context);
1448
+ * try {
1449
+ * const result = await resolution.getResult();
1450
+ * if (result && result.broadcast) {
1451
+ * console.log(`${resolution.source} returned a channel with id ${result.id}`);
1452
+ * } else if (result){
1453
+ * console.log(`${resolution.source} returned data: ${JSON.stringify(result)}`);
1454
+ * } else {
1455
+ * console.error(`${resolution.source} didn't return data`
1456
+ * }
1457
+ * } catch(error) {
1458
+ * console.error(`${resolution.source} returned an error: ${error}`);
1459
+ * }
1460
+ *
1461
+ * // Use metadata about the resolving app instance to target a further intent
1462
+ * await agent.raiseIntent("intentName", context, resolution.source);
1463
+ * ```
1464
+ */
1465
+ declare interface IntentResolution_2 {
1466
+ /**
1467
+ * Identifier for the app instance that was selected (or started) to resolve the intent.
1468
+ * `source.instanceId` MUST be set, indicating the specific app instance that
1469
+ * received the intent.
1470
+ */
1471
+ readonly source: AppIdentifier;
1472
+ /**
1473
+ * The intent that was raised. May be used to determine which intent the user
1474
+ * chose in response to `fdc3.raiseIntentForContext()`.
1475
+ */
1476
+ readonly intent: string;
1477
+ /**
1478
+ * The version number of the Intents schema being used.
1479
+ */
1480
+ readonly version?: string;
1481
+ /**
1482
+ * Retrieves a promise that will resolve to `Context` data returned
1483
+ * by the application that resolves the raised intent, a `Channel`
1484
+ * established and returned by the app resolving the intent or void.
1485
+ *
1486
+ * A `Channel` returned MAY be of the `PrivateChannel` type. The
1487
+ * client can then `addContextListener()` on that channel to, for example,
1488
+ * receive a stream of data.
1489
+ *
1490
+ * If an error occurs (i.e. an error is thrown by the handler function,
1491
+ * the promise it returns is rejected, or the promise resolved to an invalid
1492
+ * type) then the Desktop Agent MUST reject the promise returned by the
1493
+ * `getResult()` function of the `IntentResolution` with a string from
1494
+ * the `ResultError` enumeration.
1495
+ */
1496
+ getResult(): Promise<IntentResult>;
1497
+ }
1498
+
1499
+ /**
1500
+ * Intents can return results that are either context data objects
1501
+ * or a reference to a Channel.
1502
+ */
1503
+ declare type IntentResult = Context_2 | Channel_2 | void;
1504
+
1505
+ declare enum Intents {
1506
+ StartCall = "StartCall",
1507
+ StartChat = "StartChat",
1508
+ ViewChart = "ViewChart",
1509
+ ViewContact = "ViewContact",
1510
+ ViewQuote = "ViewQuote",
1511
+ ViewNews = "ViewNews",
1512
+ ViewInstrument = "ViewInstrument",
1513
+ ViewAnalysis = "ViewAnalysis"
1514
+ }
1515
+
1516
+ declare enum Intents_2 {
1517
+ StartCall = "StartCall",
1518
+ StartChat = "StartChat",
1519
+ StartEmail = "StartEmail",
1520
+ ViewAnalysis = "ViewAnalysis",
1521
+ ViewChart = "ViewChart",
1522
+ ViewContact = "ViewContact",
1523
+ ViewHoldings = "ViewHoldings",
1524
+ ViewInstrument = "ViewInstrument",
1525
+ ViewInteractions = "ViewInteractions",
1526
+ ViewNews = "ViewNews",
1527
+ ViewOrders = "ViewOrders",
1528
+ ViewProfile = "ViewProfile",
1529
+ ViewQuote = "ViewQuote",
1530
+ ViewResearch = "ViewResearch"
1531
+ }
1532
+
1533
+ /**
1534
+ * SPDX-License-Identifier: Apache-2.0
1535
+ * Copyright 2019 FINOS FDC3 contributors - see NOTICE file
1536
+ */
1537
+ declare interface Listener {
1538
+ /**
1539
+ * Unsubscribe the listener object.
1540
+ */
1541
+ unsubscribe(): void;
1542
+ }
1543
+
1544
+ /**
1545
+ * SPDX-License-Identifier: Apache-2.0
1546
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1547
+ */
1548
+ declare interface Listener_2 {
1549
+ /**
1550
+ * Unsubscribe the listener object.
1551
+ */
1552
+ unsubscribe(): void;
1553
+ }
1554
+
1555
+ declare interface Nothing {
1556
+ type: string;
1557
+ id?: {
1558
+ [key: string]: any;
1559
+ };
1560
+ name?: string;
1561
+ [property: string]: any;
1562
+ }
1563
+
1564
+ /**
1565
+ * SPDX-License-Identifier: Apache-2.0
1566
+ * Copyright 2019 FINOS FDC3 contributors - see NOTICE file
1567
+ */
1568
+ declare enum OpenError {
1569
+ AppNotFound = "AppNotFound",
1570
+ ErrorOnLaunch = "ErrorOnLaunch",
1571
+ AppTimeout = "AppTimeout",
1572
+ ResolverUnavailable = "ResolverUnavailable"
1573
+ }
1574
+
1575
+ /**
1576
+ * SPDX-License-Identifier: Apache-2.0
1577
+ * Copyright FINOS FDC3 contributors - see NOTICE file
1578
+ */
1579
+ /** Constants representing the errors that can be encountered when calling the `open` method on the DesktopAgent object (`fdc3`). */
1580
+ declare enum OpenError_2 {
1581
+ /** Returned if the specified application is not found.*/
1582
+ AppNotFound = "AppNotFound",
1583
+ /** Returned if the specified application fails to launch correctly.*/
1584
+ ErrorOnLaunch = "ErrorOnLaunch",
1585
+ /** Returned if the specified application launches but fails to add a context listener in order to receive the context passed to the `fdc3.open` call.*/
1586
+ AppTimeout = "AppTimeout",
1587
+ /** Returned if the FDC3 desktop agent implementation is not currently able to handle the request.*/
1588
+ ResolverUnavailable = "ResolverUnavailable",
1589
+ /** Returned if a call to the `open` function is made with an invalid context argument. Contexts should be Objects with at least a `type` field that has a `string` value.*/
1590
+ MalformedContext = "MalformedContext"
1591
+ }
1592
+
1593
+ declare interface Organization {
1594
+ id: OrganizationID;
1595
+ type: string;
1596
+ name?: string;
1597
+ }
1598
+
1599
+ declare interface Organization_2 {
1600
+ id: OrganizationID_2;
1601
+ type: string;
1602
+ name?: string;
1603
+ [property: string]: any;
1604
+ }
1605
+
1606
+ declare interface OrganizationID {
1607
+ FDS_ID?: string;
1608
+ LEI?: string;
1609
+ PERMID?: string;
1610
+ }
1611
+
1612
+ declare interface OrganizationID_2 {
1613
+ FDS_ID?: string;
1614
+ LEI?: string;
1615
+ PERMID?: string;
1616
+ [property: string]: any;
1617
+ }
1618
+
1619
+ declare interface Portfolio {
1620
+ positions: Position[];
1621
+ type: string;
1622
+ id?: {
1623
+ [key: string]: string;
1624
+ };
1625
+ name?: string;
1626
+ }
1627
+
1628
+ declare interface Portfolio_2 {
1629
+ positions: PositionElement[];
1630
+ type: string;
1631
+ id?: {
1632
+ [key: string]: any;
1633
+ };
1634
+ name?: string;
1635
+ [property: string]: any;
1636
+ }
1637
+
1638
+ declare interface Position {
1639
+ holding: number;
1640
+ instrument: Instrument;
1641
+ type: string;
1642
+ id?: {
1643
+ [key: string]: string;
1644
+ };
1645
+ name?: string;
1646
+ }
1647
+
1648
+ declare interface Position_2 {
1649
+ holding: number;
1650
+ instrument: InstrumentElement;
1651
+ type: string;
1652
+ id?: {
1653
+ [key: string]: any;
1654
+ };
1655
+ name?: string;
1656
+ [property: string]: any;
1657
+ }
1658
+
1659
+ declare interface PositionElement {
1660
+ holding: number;
1661
+ instrument: InstrumentElement;
1662
+ type: string;
1663
+ id?: {
1664
+ [key: string]: any;
1665
+ };
1666
+ name?: string;
1667
+ [property: string]: any;
1668
+ }
1669
+
1670
+ /**
1671
+ * Object representing a private context channel, which is intended to support
1672
+ * secure communication between applications, and extends the Channel interface
1673
+ * with event handlers which provide information on the connection state of both
1674
+ * parties, ensuring that desktop agents do not need to queue or retain messages
1675
+ * that are broadcast before a context listener is added and that applications
1676
+ * are able to stop broadcasting messages when the other party has disconnected.
1677
+ *
1678
+ * It is intended that Desktop Agent implementations:
1679
+ * - SHOULD restrict external apps from listening or publishing on this channel.
1680
+ * - MUST prevent private channels from being retrieved via fdc3.getOrCreateChannel.
1681
+ * - MUST provide the `id` value for the channel as required by the Channel interface.
1682
+ */
1683
+ declare interface PrivateChannel extends Channel_2 {
1684
+ /**
1685
+ * Adds a listener that will be called each time that the remote app invokes
1686
+ * addContextListener on this channel.
1687
+ *
1688
+ * Desktop Agents MUST call this for each invocation of addContextListener on this
1689
+ * channel, including those that occurred before this handler was registered
1690
+ * (to prevent race conditions).
1691
+ */
1692
+ onAddContextListener(handler: (contextType?: string) => void): Listener_2;
1693
+ /**
1694
+ * Adds a listener that will be called whenever the remote app invokes
1695
+ * Listener.unsubscribe() on a context listener that it previously added.
1696
+ *
1697
+ * Desktop Agents MUST call this when disconnect() is called by the other party, for
1698
+ * each listener that they have added.
1699
+ */
1700
+ onUnsubscribe(handler: (contextType?: string) => void): Listener_2;
1701
+ /**
1702
+ * Adds a listener that will be called when the remote app terminates, for example
1703
+ * when its window is closed or because disconnect was called. This is in addition
1704
+ * to calls that will be made to onUnsubscribe listeners.
1705
+ */
1706
+ onDisconnect(handler: () => void): Listener_2;
1707
+ /**
1708
+ * May be called to indicate that a participant will no longer interact with this channel.
1709
+ *
1710
+ * After this function has been called, Desktop Agents SHOULD prevent apps from broadcasting
1711
+ * on this channel and MUST automatically call Listener.unsubscribe() for each listener that
1712
+ * they've added (causing any onUnsubscribe handler added by the other party to be called)
1713
+ * before triggering any onDisconnect handler added by the other party.
1714
+ */
1715
+ disconnect(): void;
1716
+ }
1717
+
1718
+ declare interface PurpleID {
1719
+ BBG?: string;
1720
+ CUSIP?: string;
1721
+ FDS_ID?: string;
1722
+ FIGI?: string;
1723
+ ISIN?: string;
1724
+ PERMID?: string;
1725
+ RIC?: string;
1726
+ SEDOL?: string;
1727
+ ticker?: string;
1728
+ [property: string]: any;
1729
+ }
1730
+
1731
+ declare interface PurpleMarket {
1732
+ BBG?: string;
1733
+ COUNTRY_ISOALPHA2?: string;
1734
+ MIC?: string;
1735
+ name?: string;
1736
+ [property: string]: any;
1737
+ }
1738
+
1739
+ declare interface RecipientsID {
1740
+ email?: string;
1741
+ FDS_ID?: string;
1742
+ [property: string]: any;
1743
+ }
1744
+
1745
+ declare interface RecipientsObject {
1746
+ id?: RecipientsID;
1747
+ type: string;
1748
+ name?: string;
1749
+ contacts?: ContactElement[];
1750
+ [property: string]: any;
1751
+ }
1752
+
1753
+ declare enum ResolveError {
1754
+ NoAppsFound = "NoAppsFound",
1755
+ ResolverUnavailable = "ResolverUnavailable",
1756
+ ResolverTimeout = "ResolverTimeout"
1757
+ }
1758
+
1759
+ /** Constants representing the errors that can be encountered when calling the `findIntent`, `findIntentsByContext`, `raiseIntent` or `raiseIntentForContext` methods on the DesktopAgent (`fdc3`). */
1760
+ declare enum ResolveError_2 {
1761
+ /** SHOULD be returned if no apps are available that can resolve the intent and context combination.*/
1762
+ NoAppsFound = "NoAppsFound",
1763
+ /** Returned if the FDC3 desktop agent implementation is not currently able to handle the request.*/
1764
+ ResolverUnavailable = "ResolverUnavailable",
1765
+ /** Returned if the user cancelled the resolution request, for example by closing or cancelling a resolver UI.*/
1766
+ UserCancelled = "UserCancelledResolution",
1767
+ /** SHOULD be returned if a timeout cancels an intent resolution that required user interaction. Please use `ResolverUnavailable` instead for situations where a resolver UI or similar fails.*/
1768
+ ResolverTimeout = "ResolverTimeout",
1769
+ /** Returned if a specified target application is not available or a new instance of it cannot be opened. */
1770
+ TargetAppUnavailable = "TargetAppUnavailable",
1771
+ /** Returned if a specified target application instance is not available, for example because it has been closed. */
1772
+ TargetInstanceUnavailable = "TargetInstanceUnavailable",
1773
+ /** Returned if the intent and context could not be delivered to the selected application or instance, for example because it has not added an intent handler within a timeout.*/
1774
+ IntentDeliveryFailed = "IntentDeliveryFailed",
1775
+ /** Returned if a call to one of the `raiseIntent` functions is made with an invalid context argument. Contexts should be Objects with at least a `type` field that has a `string` value.*/
1776
+ MalformedContext = "MalformedContext"
1777
+ }
1778
+
1779
+ declare enum ResultError {
1780
+ /** Returned if the intent handler exited without returning a valid result (a promise resolving to a Context, Channel object or void). */
1781
+ NoResultReturned = "NoResultReturned",
1782
+ /** Returned if the Intent handler function processing the raised intent throws an error or rejects the Promise it returned. */
1783
+ IntentHandlerRejected = "IntentHandlerRejected"
1784
+ }
1785
+
1786
+ declare interface StickyID {
1787
+ BBG?: string;
1788
+ CUSIP?: string;
1789
+ FDS_ID?: string;
1790
+ FIGI?: string;
1791
+ ISIN?: string;
1792
+ PERMID?: string;
1793
+ RIC?: string;
1794
+ SEDOL?: string;
1795
+ ticker?: string;
1796
+ [property: string]: any;
1797
+ }
1798
+
1799
+ declare enum Style {
1800
+ Bar = "bar",
1801
+ Candle = "candle",
1802
+ Custom = "custom",
1803
+ Heatmap = "heatmap",
1804
+ Histogram = "histogram",
1805
+ Line = "line",
1806
+ Mountain = "mountain",
1807
+ Pie = "pie",
1808
+ Scatter = "scatter",
1809
+ StackedBar = "stacked-bar"
1810
+ }
1811
+
1812
+ declare type TargetApp = string | AppMetadata;
1813
+
1814
+ declare interface TentacledID {
1815
+ email?: string;
1816
+ FDS_ID?: string;
1817
+ [property: string]: any;
1818
+ }
1819
+
1820
+ declare interface TimeRange {
1821
+ endTime?: Date;
1822
+ startTime?: Date;
1823
+ type: string;
1824
+ id?: {
1825
+ [key: string]: any;
1826
+ };
1827
+ name?: string;
1828
+ [property: string]: any;
1829
+ }
1830
+
1831
+ declare interface TimeRangeObject {
1832
+ endTime?: Date;
1833
+ startTime?: Date;
1834
+ type: string;
1835
+ id?: {
1836
+ [key: string]: any;
1837
+ };
1838
+ name?: string;
1839
+ [property: string]: any;
1840
+ }
1841
+
1842
+ declare namespace v1_2 {
1843
+ export {
1844
+ AppIntent,
1845
+ AppMetadata,
1846
+ DisplayMetadata,
1847
+ OpenError,
1848
+ ResolveError,
1849
+ ChannelError,
1850
+ ImplementationMetadata,
1851
+ IntentMetadata,
1852
+ Listener,
1853
+ ContextTypes,
1854
+ ContextType,
1855
+ Context,
1856
+ ContactList,
1857
+ Contact,
1858
+ ContactID,
1859
+ InstrumentList,
1860
+ Instrument,
1861
+ InstrumentID,
1862
+ Country,
1863
+ CountryID,
1864
+ Organization,
1865
+ OrganizationID,
1866
+ Portfolio,
1867
+ Position,
1868
+ Convert,
1869
+ Intents,
1870
+ Channel,
1871
+ DesktopAgent,
1872
+ IntentResolution,
1873
+ TargetApp,
1874
+ ContextHandler
1875
+ }
1876
+ }
1877
+ export { v1_2 }
1878
+
1879
+ declare namespace v2_0 {
1880
+ export {
1881
+ AppIdentifier,
1882
+ AppIntent_2 as AppIntent,
1883
+ AppMetadata_2 as AppMetadata,
1884
+ ContextMetadata,
1885
+ DisplayMetadata_2 as DisplayMetadata,
1886
+ OpenError_2 as OpenError,
1887
+ ResolveError_2 as ResolveError,
1888
+ ResultError,
1889
+ ChannelError_2 as ChannelError,
1890
+ Icon,
1891
+ Image_2 as Image,
1892
+ ImplementationMetadata_2 as ImplementationMetadata,
1893
+ IntentMetadata_2 as IntentMetadata,
1894
+ Listener_2 as Listener,
1895
+ ContextTypes_2 as ContextTypes,
1896
+ ContextType_2 as ContextType,
1897
+ Chart,
1898
+ InstrumentElement,
1899
+ PurpleID,
1900
+ PurpleMarket,
1901
+ TimeRangeObject,
1902
+ Style,
1903
+ ChatInitSettings,
1904
+ ContactListObject,
1905
+ ContactElement,
1906
+ FluffyID,
1907
+ Contact_2 as Contact,
1908
+ TentacledID,
1909
+ ContactList_2 as ContactList,
1910
+ Context_2 as Context,
1911
+ Country_2 as Country,
1912
+ CountryID_2 as CountryID,
1913
+ Currency,
1914
+ CurrencyID,
1915
+ Email,
1916
+ RecipientsObject,
1917
+ RecipientsID,
1918
+ Instrument_2 as Instrument,
1919
+ StickyID,
1920
+ FluffyMarket,
1921
+ InstrumentList_2 as InstrumentList,
1922
+ Nothing,
1923
+ Organization_2 as Organization,
1924
+ OrganizationID_2 as OrganizationID,
1925
+ Portfolio_2 as Portfolio,
1926
+ PositionElement,
1927
+ Position_2 as Position,
1928
+ TimeRange,
1929
+ Valuation,
1930
+ Convert_2 as Convert,
1931
+ Intents_2 as Intents,
1932
+ Channel_2 as Channel,
1933
+ DesktopAgent_2 as DesktopAgent,
1934
+ IntentResolution_2 as IntentResolution,
1935
+ PrivateChannel,
1936
+ ContextHandler_2 as ContextHandler,
1937
+ IntentResult,
1938
+ IntentHandler
1939
+ }
1940
+ }
1941
+ export { v2_0 }
1942
+
1943
+ declare interface Valuation {
1944
+ CURRENCY_ISOCODE: string;
1945
+ expiryTime?: Date;
1946
+ price?: number;
1947
+ type: string;
1948
+ valuationTime?: Date;
1949
+ value: number;
1950
+ id?: {
1951
+ [key: string]: any;
1952
+ };
1953
+ name?: string;
1954
+ [property: string]: any;
1955
+ }
1956
+
1957
+ export declare type Version = (typeof versions)[keyof typeof versions];
1958
+
1959
+ export declare const versions: {
1960
+ readonly v1_2: "1.2";
1961
+ readonly v2_0: "2.0";
1962
+ };
1963
+
1964
+ export { }