Skip to main content
Version: Next

Types

FDC3 API operations make use of several type declarations.

AppIdentifier

Identifies an application, or instance of an application, and is used to target FDC3 API calls at specific applications.

An AppIdentifier will always include at least an appId property, which can be used with fdc3.open, fdc3.raiseIntent etc.. An appId is intended to reference a specific record from an App Directory, which it uniquely identifies within that App Directory.

The appId may be unqualified or fully-qualified as described in the API overview and App Directory Parts of the Standard and may be resolved and used interchangeably as described in the API overview.

If the instanceId field is set then the AppIdentifier object represents a specific instance of the application that may be addressed using that Id.

interface AppIdentifier {
/** The unique application identifier located within a specific application
* directory instance. An example of an appId might be 'app@sub.root'.
*/
readonly appId: string;

/** An optional instance identifier, indicating that this object represents a
* specific instance of the application described.
*/
readonly instanceId?: string;

/** The Desktop Agent that the app is available on. Used in Desktop Agent
* Bridging to identify the Desktop Agent to target.
* @experimental
**/
readonly desktopAgent?: string;
}

See also:

Context

interface Context {
id?: { [key: string]: string };
name?: string;
type: string;
}

The base interface that all contexts should extend: a context data object adhering to the FDC3 Context Data specification.

This means that it must at least have a type property that indicates what type of data it represents, e.g. 'fdc3.contact'. The type property of context objects is important for certain FDC3 operations, like Channel.getCurrentContext and DesktopAgent.addContextListener, which allows you to filter contexts by their type.

See also:

ContextWithMetadata

type ContextWithMetadata = {
context: Context;
metadata: ContextMetadata;
};

Represents a context object paired with its associated metadata. Returned by Channel.getCurrentContextWithMetadata() to allow retrieval of both the current context and the ContextMetadata that was provided when it was broadcast. May also be returned by an IntentHandler to include app-provided metadata alongside a context result, which will be merged with Desktop Agent generated metadata and made available to the raising app via IntentResolution.getResultMetadata().

See also:

ContextHandler

type ContextHandler = (context: Context, metadata: ContextMetadata) => void;

Describes a callback that handles a context event. Used when attaching listeners for context broadcasts.

Metadata about each context message received, including the app that originated the message and a timestamp, MUST be provided by the Desktop Agent implementation. Apps raising intents MAY provide additional metadata (such as a traceId, signature or custom metadata), which the Desktop Agent MUST pass on to the handler.

See also:

DesktopAgentIdentifier

/** @experimental */
interface DesktopAgentIdentifier {
/** Used in Desktop Agent Bridging to attribute or target a message to a
* particular Desktop Agent.**/
readonly desktopAgent: string;
}

(Experimental) Identifies a particular Desktop Agent in Desktop Agent Bridging scenarios where a request needs to be directed to a Desktop Agent rather than a specific app, or a response message is returned by the Desktop Agent (or more specifically its resolver) rather than a specific app. Used as a substitute for AppIdentifier in cases where no app details are available or are appropriate.

See also:

IntentHandler

type IntentHandler = (
context: Context,
metadata: ContextMetadata
) => Promise<Context | ContextWithMetadata | Channel | PrivateChannel | void> | void;

Describes a callback that handles a context event and may return a promise of a Context, ContextWithMetadata, Channel, PrivateChannel or void to be returned to the application that raised the intent. Used when attaching listeners for raised intents.

Metadata about each intent & context message received, including the app that originated the message and a timestamp, MUST be provided by the Desktop Agent implementation. Apps raising intents MAY provide additional metadata (such as a traceId, signature or custom metadata), which the Desktop Agent MUST pass on to the handler.

An IntentHandler MAY return a ContextWithMetadata object instead of a plain Context to include app-provided metadata (e.g. a traceId or signature) alongside the context result. The Desktop Agent will merge this with its own generated metadata and make the combined ContextMetadata available to the raising app via IntentResolution.getResultMetadata(). IntentResolution.getResult() will still return only the Context portion.

See also:

IntentResult

type IntentResult = Context | Channel | void;

Describes results returned by IntentResolution.getResult() after an intent is resolved. Note that IntentHandler functions may also return ContextWithMetadata to include app-provided metadata alongside a context result; in that case getResult() still returns only the Context portion, while the metadata is available via IntentResolution.getResultMetadata().

Represented as a union type in TypeScript, however, this type may be rendered as an interface in other languages that both the Context and Channel types implement, allowing either to be returned by an IntentHandler.

See also:

Listener

A Listener object is returned when an application subscribes to intents or context broadcasts via the addIntentListener, addContextListener or addEventListener on the DesktopAgent object or (PrivateChannel#addeventlistener) on the PrivateChannel object.

interface Listener {
unsubscribe(): Promise<void>;
}

unsubscribe

unsubscribe(): Promise<void>;

Allows an application to unsubscribe from listening to intents or context broadcasts.

See also: