Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolba committed Oct 21, 2022
1 parent c96d414 commit 8fd3a34
Show file tree
Hide file tree
Showing 23 changed files with 1,946 additions and 682 deletions.
1,316 changes: 652 additions & 664 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dependencies": {
"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@finos/fdc3": "^1.2.0",
"@finos/fdc3": "2.0.0-beta.2",
"@fontsource/roboto": "^4.5.3",
"@mui/icons-material": "^5.4.4",
"@mui/material": "^5.4.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/types/FDC3Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface DirectoryIntent {
*/
export interface ChannelData {
id: string;
type: string;
type: 'user' | 'app' | 'private';
displayMetadata?: ChannelMetadata;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { join } from 'path';
import { randomUUID } from 'crypto';
import { RUNTIME_TOPICS } from './handlers/runtime/topics';

const VIEW_PRELOAD = join(__dirname, '../../preload/dist/view/index.cjs');
const VIEW_PRELOAD = join(__dirname, '../../preload/dist/fdc3-2.0/index.cjs');

const HOME_PRELOAD = join(__dirname, '../../preload/dist/systemView/index.cjs');

Expand Down
3 changes: 1 addition & 2 deletions packages/preload/exposedInMainWorld.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
interface Window {
readonly home: { getApps: () => Promise<unknown>; };
readonly fdc3: import("/Users/nicholaskolba/connectifi/electron-fdc3/node_modules/@finos/fdc3/dist/api/DesktopAgent").DesktopAgent;
readonly fdc3: import("/Users/nicholaskolba/connectifi/electron-fdc3/packages/preload/src/fdc3-1.2/types/DesktopAgent").DesktopAgent;
readonly sail: { isConnected: () => boolean; isReady: () => void; joinChannel: (channel: string) => void; leaveChannel: () => void; hideWindow: () => void; resolveIntent: (data: any) => void; versions: NodeJS.ProcessVersions; getApps: () => Promise<unknown>; tabs: { select: (selectedId: string) => void; tearOut: (tabId: string) => void; new: () => void; drop: (frameTarget: boolean) => void; dragStart: (selected: string) => void; close: (tabId: string) => void; }; menu: { openTools: (clientX: number, clientY: number) => void; openChannelPicker: (mouseX: number, mouseY: number) => void; }; search: { hideResultsWindow: () => void; searchDirectory: (query: string) => void; selectResult: (selection: string) => void; }; };
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import {
FDC3MessageData,
FDC3Response,
} from '../../../main/src/types/FDC3Message';
import { DesktopAgent, Listener } from '@finos/fdc3';
import {
AppIntent,
Context,
DisplayMetadata,
ContextHandler,
Channel,
ImplementationMetadata,
IntentResolution,
TargetApp,
} from '@finos/fdc3';
import { DesktopAgent } from './types/DesktopAgent';
import { Listener } from './types/Listener';
import { AppIntent } from './types/AppIntent';
import { Context } from '@finos/fdc3';
import { DisplayMetadata } from './types/DisplayMetadata';
import { ContextHandler, TargetApp } from './types/Types';
import { Channel } from './types/Channel';
import { ImplementationMetadata } from './types/ImplementationMetadata';
import { IntentResolution } from './types/IntentResolution';

import { FDC3Event } from '../../../main/src/types/FDC3Event';
import { ChannelData } from '../../../main/src/types/FDC3Data';
import { FDC3EventEnum } from '../../../main/src/types/FDC3Event';
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions packages/preload/src/fdc3-1.2/types/AppIntent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 FINOS FDC3 contributors - see NOTICE file
*/

import { AppMetadata } from './AppMetadata';
import { IntentMetadata } from './IntentMetadata';

/**
* An interface that relates an intent to apps
*/
export interface AppIntent {
readonly intent: IntentMetadata;
readonly apps: Array<AppMetadata>;
}
33 changes: 33 additions & 0 deletions packages/preload/src/fdc3-1.2/types/AppMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 FINOS FDC3 contributors - see NOTICE file
*/

/**
* App definition as provided by the application directory
*/
export interface AppMetadata {
/** The unique app name that can be used with the open and raiseIntent calls. */
readonly name: string;

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

/** The Version of the application. */
readonly version?: string;

/** A more user-friendly application title that can be used to render UI elements */
readonly title?: string;

/** A tooltip for the application that can be used to render UI elements */
readonly tooltip?: string;

/** A longer, multi-paragraph description for the application that could include markup */
readonly description?: string;

/** A list of icon URLs for the application that can be used to render UI elements */
readonly icons?: Array<string>;

/** A list of image URLs for the application that can be used to render UI elements */
readonly images?: Array<string>;
}
75 changes: 75 additions & 0 deletions packages/preload/src/fdc3-1.2/types/Channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 FINOS FDC3 contributors - see NOTICE file
*/

import { Context } from '../context/ContextTypes';
import { ContextHandler } from './Types';
import { DisplayMetadata } from './DisplayMetadata';
import { Listener } from './Listener';

/**
* Object representing a context channel.
*/
export interface Channel {
/**
* Constant that uniquely identifies this channel.
*/
readonly id: string;

/**
* Uniquely defines each channel type.
*/
readonly type: string;

/**
* Channels may be visualized and selectable by users. DisplayMetadata may be used to provide hints on how to see them.
* For app channels, displayMetadata would typically not be present
*/
readonly displayMetadata?: DisplayMetadata;

/**
* Broadcasts the given context on this channel. This is equivalent to joining the channel and then calling the
* top-level FDC3 `broadcast` function.
*
* Note that this function can be used without first joining the channel, allowing applications to broadcast on
* channels that they aren't a member of.
*
* 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.
*
* `Error` with a string from the `ChannelError` enumeration.
*/
broadcast(context: Context): void;

/**
* Returns the last context that was broadcast on this channel. All channels initially have no context, until a
* context is broadcast on the channel. If there is not yet any context on the channel, this method
* will return `null`.
*
* The context of a channel will be captured regardless of how the context is broadcasted on this channel - whether
* using the top-level FDC3 `broadcast` function, or using the channel-level {@link broadcast} function on this
* object.
*
* Optionally a {@link contextType} can be provided, in which case the current context of the matching type will
* be returned (if any). Desktop agent implementations may decide to record contexts by type, in which case it will
* be possible to get the most recent context of the type specified, but this is not guaranteed.
*
* `Error` with a string from the `ChannelError` enumeration.
*/
getCurrentContext(contextType?: string): Promise<Context | null>;

/**
* Adds a listener for incoming contexts whenever a broadcast happens on this channel.
* @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`.
*/
addContextListener(handler: ContextHandler): Listener;

/**
* Adds a listener for incoming contexts of the specified context type whenever a broadcast happens on this channel.
*/
addContextListener(
contextType: string | null,
handler: ContextHandler,
): Listener;
}
207 changes: 207 additions & 0 deletions packages/preload/src/fdc3-1.2/types/DesktopAgent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 FINOS FDC3 contributors - see NOTICE file
*/

import { AppIntent } from './AppIntent';
import { Channel } from './Channel';
import { ContextHandler, TargetApp } from './Types';
import { IntentResolution } from './IntentResolution';
import { Listener } from './Listener';
import { Context } from '../context/ContextTypes';
import { ImplementationMetadata } from './ImplementationMetadata';

/**
* 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.
*/

export interface DesktopAgent {
/**
* Launches an app by target, which can be optionally a string like a name, or an AppMetadata object.
*
* 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.
*
* If opening errors, it returns an `Error` with a string from the `OpenError` enumeration.
*
* ```javascript
* //no context and string as target
* agent.open('myApp');
* //no context and AppMetadata object as target
* agent.open({name: 'myApp', title: 'The title for the application myApp.', description: '...'});
* //with context
* agent.open('myApp', context);
* ```
*/
open(app: TargetApp, context?: Context): Promise<void>;

/**
* 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` enumeration.
*
* ```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);
* ```
*/
findIntent(intent: string, context?: Context): Promise<AppIntent>;

/**
* Find all the avalable intents for a particular context.
*
* findIntents 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` enumeration.
*
* ```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.findIntentsByContext(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);
* ```
*/
findIntentsByContext(context: Context): Promise<Array<AppIntent>>;

/**
* Publishes context to other apps on the desktop.
*
* 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.
*
* ```javascript
* agent.broadcast(context);
* ```
*/
broadcast(context: Context): void;

/**
* Raises an intent to the desktop agent to resolve.
* ```javascript
* //Find apps to resolve an intent to start a chat with a given contact
* const appIntent = await fdc3.findIntent("StartChat", context);
* //use the returned AppIntent object to target one of the returned chat apps with the context
* await fdc3.raiseIntent("StartChat", context, appIntent.apps[0].name);
* //or use one of the AppMetadata objects returned in the AppIntent object's 'apps' array
* await fdc3.raiseIntent("StartChat", context, appMetadata);
* ```
*/
raiseIntent(
intent: string,
context: Context,
app?: TargetApp,
): Promise<IntentResolution>;

/**
* Raises a context to the desktop agent to resolve with one of the possible Intents for that context.
* ```javascript
* await fdc3.raiseIntentForContext(context);
* ```
*/
raiseIntentForContext(
context: Context,
app?: TargetApp,
): Promise<IntentResolution>;

/**
* Adds a listener for incoming Intents from the Agent.
*/
addIntentListener(intent: string, handler: ContextHandler): Listener;

/**
* Adds a listener for incoming context broadcast from the Desktop Agent.
* @deprecated use `addContextListener(null, handler)` instead of `addContextListener(handler)`.
*/
addContextListener(handler: ContextHandler): Listener;

/**
* Adds a listener for the broadcast of a specific type of context object.
*/
addContextListener(
contextType: string | null,
handler: ContextHandler,
): Listener;

/**
* Retrieves a list of the System channels available for the app to join
*/
getSystemChannels(): Promise<Array<Channel>>;

/**
* Joins the app to the specified channel.
* An app can only be joined to one channel at a time.
* Rejects with error if the channel is unavailable or the join request is denied.
* `Error` with a string from the `ChannelError` enumeration.
*/
joinChannel(channelId: string): Promise<void>;

/**
* Returns a channel with the given identity. Either stands up a new channel or returns an existing channel.
*
* It is up to applications to manage how to share knowledge of these custom channels across windows and to manage
* channel ownership and lifecycle.
*
* `Error` with a string from the `ChannelError` enumeration.
*/
getOrCreateChannel(channelId: string): Promise<Channel>;

/**
* Returns the `Channel` object for the current channel membership.
*
* Returns `null` if the app is not joined to a channel.
*/
getCurrentChannel(): Promise<Channel | null>;

/**
* Removes the app from any channel membership.
*
* Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be
* in a no-op when the app is not on a channel.
*/
leaveCurrentChannel(): Promise<void>;

/**
* Retrieves information about the FDC3 Desktop Agent implementation, such as
* the implemented version of the FDC3 specification and the name of the implementation
* provider.
*/
getInfo(): ImplementationMetadata;
}
Loading

0 comments on commit 8fd3a34

Please sign in to comment.