Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 1.0-beta version of FDC3 docs #47

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions website/pages/en/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');

const CompLibrary = require('../../core/CompLibrary');

const Container = CompLibrary.Container;

const CWD = process.cwd();

const versions = require(`${CWD}/versions.json`);

function Versions(props) {
const {config: siteConfig} = props;
const latestVersion = versions[0];
const repoUrl = `https://github.com/${siteConfig.organizationName}/${
siteConfig.projectName
}`;
return (
<div className="docMainWrapper wrapper">
<Container className="mainContainer versionsContainer">
<div className="post">
<header className="postHeader">
<h1>{siteConfig.title} Versions</h1>
</header>
<h3 id="latest">Current version (Pre-release)</h3>
<table className="versions">
<tbody>
<tr>
<th>{latestVersion}</th>
<td>
<a href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/fdc3-intro`}>Documentation</a>
</td>
<td>
<a href={`${repoUrl}/releases/tag/v${latestVersion}`}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
<h3 id="rc">Latest version</h3>
<table className="versions">
<tbody>
<tr>
<th>master</th>
<td>
<a href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/next/fdc3-intro`}>Documentation</a>
</td>
<td>
<a href={repoUrl}>Source Code</a>
</td>
</tr>
</tbody>
</table>
<p>Here you can find the latest documentation and unreleased code.</p>
<h3 id="archive">Past Versions</h3>
<table className="versions">
<tbody>
{versions.map(
version =>
version !== latestVersion && (
<tr>
<th>{version}</th>
<td>
<a href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${version}/fdc3-intro`}>Documentation</a>
</td>
<td>
<a href={`${repoUrl}/releases/tag/v${version}`}>Release Notes</a>
</td>
</tr>
),
)}
</tbody>
</table>
<p>
You can find past versions of this project on{' '}
<a href={repoUrl}>GitHub</a>.
</p>
</div>
</Container>
</div>
);
}

module.exports = Versions;
14 changes: 14 additions & 0 deletions website/versioned_docs/version-1.0-beta/api/Context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: version-1.0-beta-Context
sidebar_label: Context
title: Context
hide_title: true
original_id: Context
---
# `Context`

```typescript
type Context = object;
```

The base object that all contexts should extend.
238 changes: 238 additions & 0 deletions website/versioned_docs/version-1.0-beta/api/DesktopAgent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
---
id: version-1.0-beta-DesktopAgent
sidebar_label: DesktopAgent
title: DesktopAgent
hide_title: true
original_id: DesktopAgent
---
# `DesktopAgent`

A Desktop Agent is a desktop component (or aggregate of components) that serves as a launcher and message router (broker) for applications in its domain.

A Desktop Agent can be connected to one or more App Directories and will use directories for application identity and discovery. Typically, a Desktop Agent will contain the proprietary logic of a given platform, handling functionality like explicit application interop workflows where security, consistency, and implementation requirements are proprietary.

## Methods

### `open`

```typescript
open(name: string, context?: Context): Promise<void>;
```

Launches/links to an app by name.

If a [`Context`](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.
If opening errors, it returns an `Error` with a string from the [`OpenError`](OpenError) enumeration.

#### Example
```javascript
//no context
await agent.open('myApp');

//with context
await agent.open('myApp', context);
```

#### See also
* [`Context`](Context)
* [`OpenError`](Errors#OpenError)

### `findIntent`

```typescript
findIntent(intent: string, context?: Context): Promise<AppIntent>;
```

Find out more information about a particular intent by passing its name, and optionally its context.

_findIntent_ is effectively granting programmatic access to the Desktop Agent's resolver.
A promise resolving to the intent, its metadata and metadata about the apps that registered it is returned.
This can be used to raise the intent against a specific app.


If the resolution fails, the promise will return an `Error` with a string from the [`ResolveError`](Errors#ResolveError) enumeration.

#### Examples
```javascript
// I know 'StartChat' exists as a concept, and want to know more about it ...
const appIntent = await agent.findIntent("StartChat");
// returns a single AppIntent:
// {
// intent: { name: "StartChat", displayName: "Chat" },
// apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
// }

// raise the intent against a particular app
await agent.raiseIntent(appIntent.intent.name, context, appIntent.apps[0].name);
```

#### See also
* [`ResolveError`](Errors#ResolveError)

### `findIntentsByContext`

```typescript
findIntentsByContext(context: Context): Promise<Array<AppIntent>>;
```

Find all the avalable intents for a particular context.
_findIntentsByContext_ is effectively granting programmatic access to the Desktop Agent's resolver.
A promise resolving to all the intents, their metadata and metadata about the apps that registered it is returned, based on the context types the intents have registered.

If the resolution fails, the promise will return an `Error` with a string from the [`ResolveError`](Errors#ResolveError) enumeration.

#### Examples
```javascript
// I have a context object, and I want to know what I can do with it, hence, I look for for intents...
const appIntents = await agent.findIntentsForContext(context);

// returns for example:
// [{
// intent: { name: "StartCall", displayName: "Call" },
// apps: [{ name: "Skype" }]
// },
// {
// intent: { name: "StartChat", displayName: "Chat" },
// apps: [{ name: "Skype" }, { name: "Symphony" }, { name: "Slack" }]
// }];

// select a particular intent to raise
const startChat = appIntents[1];

// target a particular app
const selectedApp = startChat.apps[0];

// raise the intent, passing the given context, targeting the app
await agent.raiseIntent(startChat.intent.name, context, selectedApp.name);
```

#### See also
* [`ResolveError`](Errors#resolveerror)

### `broadcast`
```typescript
broadcast(context: Context): void;
```

Publishes context to other apps on the desktop.

#### Examples
```javascript
agent.broadcast(context);
```
#### See also
* [addContextListener](#addcontextlistener)

### `raiseIntent`

```typescript
raiseIntent(intent: string, context: Context, target?: string): Promise<IntentResolution>;
```
Raises an intent to the desktop agent to resolve.
#### Examples
```javascript
//raise an intent to start a chat with a given contact
const intentR = await agent.findIntents("StartChat", context);
//use the IntentResolution object to target the same chat app with a new context
agent.raiseIntent("StartChat", newContext, intentR.source);
```
#### See also
* [`IntentResolution`](#intentresolution)

### `addIntentListener`
```typescript
addIntentListener(intent: string, handler: (context: Context) => void): Listener;
```
Adds a listener for incoming Intents from the Agent.
#### See also
* [`Listener`](#listener)
* [`Context`](Context)

### `addContextListener`
```typescript
addContextListener(handler: (context: Context) => void): Listener;
```
Adds a listener for incoming context broadcast from the Desktop Agent.

#### See also
* [`Listener`](#listener)
* [`Context`](Context)

## Return Types

### `AppIntent`

```typescript
interface AppIntent {
intent: IntentMetadata;
apps: Array<AppMetadata>;
}
```
An interface that represents the binding of an intent to apps

#### See also
* [`IntentMetadata`](#intentmetadata)
* [`AppMetadata`](#appmetadata)

### `IntentMetadata`

```typescript
interface IntentMetadata {
name: string;
displayName: string;
}
```

The Interface used to describe an Intent within the platform.

### `AppMetadata`

```typescript
interface AppMetadata {
name: string;
}
```

App metadata is Desktop Agent specific - but should always support a name property.

### `IntentResolution`

```typescript
interface IntentResolution {
source: string;
data?: object;
version: string;
}
```

IntentResolution provides a standard format for data returned upon resolving an intent.

#### Example
```javascript
//resolve a "Chain" type intent
var intentR = await agent.raiseIntent("intentName", context);
//resolve a "Client-Service" type intent with data response
var intentR = await agent.raiseIntent("intentName", context);
var dataR = intentR.data;
```

#### See also
* [`DesktopAgent.raiseIntent`](#raiseintent)


### `Listener`

```typescript
interface Listener {
unsubscribe();
}
```

A Listener object is returned when an application subscribes to intents or context broadcasts via the [`addIntentListener`](DesktopAgent#addintentlistener) or [`addContextListener`](DesktopAgent#addcontextlistener) methods on the [DesktopAgent](DesktopAgent) object.
The `unsubscribe` method on the listener object allows the application to cancel the subscription.

#### See also
* [`DesktopAgent.addIntentListener`](#addintentlistener)
* [`DesktopAgent.addContextListener`](#addcontextlistener)

40 changes: 40 additions & 0 deletions website/versioned_docs/version-1.0-beta/api/Errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
id: version-1.0-beta-Errors
sidebar_label: Errors
title: Errors
hide_title: true
original_id: Errors
---

## `OpenError`

```typescript
enum OpenError {
AppNotFound = "AppNotFound",
ErrorOnLaunch = "ErrorOnLaunch",
AppTimeout = "AppTimeout",
ResolverUnavailable = "ResolverUnavailable"
}
```

Contains constants representing the errors that can be encountered when calling the [`open`](DesktopAgent#open) method on the [DesktopAgent](DesktopAgent) object.

#### See also
* [`DesktopAgent.open`](DesktopAgent#open)


## `ResolveError`

```typescript
enum ResolveError {
NoAppsFound = "NoAppsFound",
ResolverUnavailable = "ResolverUnavailable",
ResolverTimeout = "ResolverTimeout"
}
```

Contains constants representing the errors that can be encountered when calling the [`findIntent`](DesktopAgent#findintent) or [`findIntentsByContext`](DesktopAgent#findintentsbycontext) methods on the [DesktopAgent](DesktopAgent).

#### See also
* [`DesktopAgent.findIntent`](DesktopAgent#findintent)
* [`DesktopAgent.findIntentsByContext`](DesktopAgent#findintentsbycontext)
Loading