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

FDC3 For Web Browsers Implementation #1309

Open
wants to merge 835 commits into
base: main
Choose a base branch
from
Open

FDC3 For Web Browsers Implementation #1309

wants to merge 835 commits into from

Conversation

robmoffat
Copy link
Member

@robmoffat robmoffat commented Aug 5, 2024

Implementation PR for FDC3 for the Web (#896)

This PR primarily implements the getAgent() function (in the fdc3-get-agent package) as defined by the FDC3 Web Connection Protocol (WCP) and a DesktopAgentProxy (in the fdc3-agent-proxy package) that it uses to implement communication with browser-based Desktop Agents via the FDC3 Desktop Agent Communication Protocol (DACP).

Additionally, the FDC3 repository is refactored to be a monorepo supported by npm workspaces. The existing repository was split into fdc3-context (context type definitions), fdc3-schems (bridging and DACP protocol messages) and fdc3-standard (existing API TypeScript definitions, Intents and App Directory) packages. A testing package was added with tooling used in multiple packages for testing.

These packages are rolled up for release on NPM by an fdc3 package (publishing to the existing @finos/fdc3 NPM package). Previous releases provided both ES6 and CommonJs modules within a single package - this release will only provide ES6, with a separate fdc3-commonjs module provided for backwards compatibility (will release at @finos/fdc3-commonjs).

Finally, a reference implementation, demo for FDC3 in a Web Browser and reference channel selector and intent resolver UIs (that can be injected into an app by getAgent) are provided in the toolbox/fdc3-for-web package.

@julianna-ciq

This comment was marked as outdated.

Copy link
Contributor

@julianna-ciq julianna-ciq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the addon and fdc3-agent-proxy package. More reviews to come...

package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
packages/addon/index.html Outdated Show resolved Hide resolved
packages/addon/package.json Outdated Show resolved Hide resolved
packages/addon/src/intent_resolver.ts Outdated Show resolved Hide resolved
Then "{result}" is an error with message "TargetAppUnavailable"

Scenario: void is returned in the result
Given Raise Intent will return no result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given Raise Intent will return no result
Given Raise Intent returns no result

| OrderFood | fdc3.instrument | AAPL | chipShop | c1 | raiseIntentRequest |

Scenario: Context Data is returned in the result
Given Raise Intent will return a context of "{instrumentContext}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given Raise Intent will return a context of "{instrumentContext}"
Given Raise Intent returns a context of "{instrumentContext}"

| OrderFood | fdc3.instrument | AAPL | raiseIntentRequest |

Scenario: App Channel is returned in the result
Given Raise Intent will return an app channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given Raise Intent will return an app channel
Given Raise Intent returns an app channel

| OrderFood | fdc3.instrument | AAPL | raiseIntentRequest |

Scenario: User Channel is returned in the result
Given Raise Intent will return a user channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given Raise Intent will return a user channel
Given Raise Intent returns a user channel

| OrderFood | fdc3.instrument | AAPL | raiseIntentRequest |

Scenario: Private Channel is returned in the result
Given Raise Intent will return a private channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Given Raise Intent will return a private channel
Given Raise Intent returns a private channel

Copy link
Contributor

@julianna-ciq julianna-ciq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviews for the fdc3-get-agent package

packages/fdc3-context/package.json Outdated Show resolved Hide resolved
packages/fdc3-context/package.json Outdated Show resolved Hide resolved
packages/fdc3-get-agent/package.json Outdated Show resolved Hide resolved
packages/fdc3-get-agent/test/support/MockFDC3Server.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just starting a review - have only really got through addon

package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
packages/README.md Outdated Show resolved Hide resolved
packages/addon/index.html Outdated Show resolved Hide resolved
packages/addon/src/channel_selector.ts Outdated Show resolved Hide resolved
packages/addon/src/intent_resolver.ts Outdated Show resolved Hide resolved
packages/addon/src/main.ts Outdated Show resolved Hide resolved
packages/fdc3-agent-proxy/package.json Outdated Show resolved Hide resolved
packages/fdc3-agent-proxy/package.json Outdated Show resolved Hide resolved
@kriswest

This comment was marked as outdated.

@robmoffat

This comment was marked as outdated.

@kriswest

This comment was marked as outdated.

@finos finos deleted a comment from github-actions bot Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

Coverage Report

Commit: 537ccfb
Base: main@4b74dec

Type Base This PR
Total Statements Coverage  97.41%  97.41% (+0%)
Total Branches Coverage  86.53%  86.53% (+0%)
Total Functions Coverage  96.85%  96.85% (+0%)
Total Lines Coverage  97.43%  97.43% (+0%)
Details (changed files)
FileStatementsBranchesFunctionsLines
packages/fdc3-agent-proxy/src/DesktopAgentProxy.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/index.ts 100% 100% 62.5% 100%
packages/fdc3-agent-proxy/src/apps/DefaultAppSupport.ts 88% 50% 100% 88%
packages/fdc3-agent-proxy/src/channels/DefaultChannel.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/channels/DefaultChannelSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/channels/DefaultPrivateChannel.ts 97.29% 66.66% 100% 97.29%
packages/fdc3-agent-proxy/src/heartbeat/DefaultHeartbeatSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentResolution.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/AbstractListener.ts 100% 60% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultContextListener.ts 100% 90% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultIntentListener.ts 100% 77.77% 100% 100%
packages/fdc3-agent-proxy/src/listeners/EventListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/HeartbeatListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/PrivateChannelEventListener.ts 93.33% 72.72% 100% 93.33%
packages/fdc3-agent-proxy/src/messaging/AbstractMessaging.ts 94.59% 100% 80% 94.59%
packages/fdc3-agent-proxy/src/util/AbstractFDC3Logger.ts 100% 94.11% 100% 100%
packages/fdc3-agent-proxy/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/util/throwIfUndefined.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/index.ts 100% 100% 28.57% 100%
packages/fdc3-get-agent/src/messaging/MessagePortMessaging.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/messaging/message-port.ts 97.43% 86.66% 100% 97.43%
packages/fdc3-get-agent/src/sessionStorage/DesktopAgentDetails.ts 97.36% 89.47% 100% 97.36%
packages/fdc3-get-agent/src/strategies/DesktopAgentPreloadLoader.ts 100% 81.25% 100% 100%
packages/fdc3-get-agent/src/strategies/FailoverHandler.ts 100% 76.47% 100% 100%
packages/fdc3-get-agent/src/strategies/HelloHandler.ts 94% 81.25% 100% 94%
packages/fdc3-get-agent/src/strategies/IdentityValidationHandler.ts 95.65% 73.33% 100% 95.65%
packages/fdc3-get-agent/src/strategies/PostMessageLoader.ts 98.48% 86.95% 100% 98.46%
packages/fdc3-get-agent/src/strategies/Timeouts.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/strategies/getAgent.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/AbstractUIComponent.ts 97.14% 71.42% 100% 97.01%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentChannelSelector.ts 100% 75% 100% 100%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentIntentResolver.ts 100% 90% 100% 100%
packages/fdc3-get-agent/src/ui/NullChannelSelector.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/NullIntentResolver.ts 100% 100% 66.66% 100%
packages/fdc3-get-agent/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/util/Uuid.ts 100% 100% 100% 100%
packages/fdc3-standard/src/index.ts 100% 100% 0% 100%
packages/fdc3-standard/src/api/Errors.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/GetAgent.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/Methods.ts 94.04% 84.05% 96.29% 95%
packages/fdc3-standard/src/api/RecommendedChannels.ts 100% 100% 100% 100%
packages/fdc3-standard/src/context/ContextType.ts 100% 100% 100% 100%
packages/fdc3-standard/src/intents/Intents.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/contextConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/intentConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/typeHelpers.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/BasicFDC3Server.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/ServerContext.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/directory/BasicDirectory.ts 96.87% 84.21% 100% 96.55%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/BroadcastHandler.ts 96.38% 86.41% 100% 96.12%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/HeartbeatHandler.ts 88.23% 71.87% 86.66% 90%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/IntentHandler.ts 95.6% 86.56% 100% 95%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/OpenHandler.ts 97.14% 86.84% 100% 97.14%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/support.ts 100% 100% 100% 100%
Details (all files)
FileStatementsBranchesFunctionsLines
packages/fdc3-agent-proxy/src/DesktopAgentProxy.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/index.ts 100% 100% 62.5% 100%
packages/fdc3-agent-proxy/src/apps/DefaultAppSupport.ts 88% 50% 100% 88%
packages/fdc3-agent-proxy/src/channels/DefaultChannel.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/channels/DefaultChannelSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/channels/DefaultPrivateChannel.ts 97.29% 66.66% 100% 97.29%
packages/fdc3-agent-proxy/src/heartbeat/DefaultHeartbeatSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentResolution.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/intents/DefaultIntentSupport.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/AbstractListener.ts 100% 60% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultContextListener.ts 100% 90% 100% 100%
packages/fdc3-agent-proxy/src/listeners/DefaultIntentListener.ts 100% 77.77% 100% 100%
packages/fdc3-agent-proxy/src/listeners/EventListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/HeartbeatListener.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/listeners/PrivateChannelEventListener.ts 93.33% 72.72% 100% 93.33%
packages/fdc3-agent-proxy/src/messaging/AbstractMessaging.ts 94.59% 100% 80% 94.59%
packages/fdc3-agent-proxy/src/util/AbstractFDC3Logger.ts 100% 94.11% 100% 100%
packages/fdc3-agent-proxy/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-agent-proxy/src/util/throwIfUndefined.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/index.ts 100% 100% 28.57% 100%
packages/fdc3-get-agent/src/messaging/MessagePortMessaging.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/messaging/message-port.ts 97.43% 86.66% 100% 97.43%
packages/fdc3-get-agent/src/sessionStorage/DesktopAgentDetails.ts 97.36% 89.47% 100% 97.36%
packages/fdc3-get-agent/src/strategies/DesktopAgentPreloadLoader.ts 100% 81.25% 100% 100%
packages/fdc3-get-agent/src/strategies/FailoverHandler.ts 100% 76.47% 100% 100%
packages/fdc3-get-agent/src/strategies/HelloHandler.ts 94% 81.25% 100% 94%
packages/fdc3-get-agent/src/strategies/IdentityValidationHandler.ts 95.65% 73.33% 100% 95.65%
packages/fdc3-get-agent/src/strategies/PostMessageLoader.ts 98.48% 86.95% 100% 98.46%
packages/fdc3-get-agent/src/strategies/Timeouts.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/strategies/getAgent.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/AbstractUIComponent.ts 97.14% 71.42% 100% 97.01%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentChannelSelector.ts 100% 75% 100% 100%
packages/fdc3-get-agent/src/ui/DefaultDesktopAgentIntentResolver.ts 100% 90% 100% 100%
packages/fdc3-get-agent/src/ui/NullChannelSelector.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/ui/NullIntentResolver.ts 100% 100% 66.66% 100%
packages/fdc3-get-agent/src/util/Logger.ts 100% 100% 100% 100%
packages/fdc3-get-agent/src/util/Uuid.ts 100% 100% 100% 100%
packages/fdc3-standard/src/index.ts 100% 100% 0% 100%
packages/fdc3-standard/src/api/Errors.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/GetAgent.ts 100% 100% 100% 100%
packages/fdc3-standard/src/api/Methods.ts 94.04% 84.05% 96.29% 95%
packages/fdc3-standard/src/api/RecommendedChannels.ts 100% 100% 100% 100%
packages/fdc3-standard/src/context/ContextType.ts 100% 100% 100% 100%
packages/fdc3-standard/src/intents/Intents.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/contextConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/intentConfiguration.ts 100% 100% 100% 100%
packages/fdc3-standard/src/internal/typeHelpers.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/BasicFDC3Server.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/ServerContext.ts 100% 100% 100% 100%
toolbox/fdc3-for-web/fdc3-web-impl/src/directory/BasicDirectory.ts 96.87% 84.21% 100% 96.55%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/BroadcastHandler.ts 96.38% 86.41% 100% 96.12%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/HeartbeatHandler.ts 88.23% 71.87% 86.66% 90%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/IntentHandler.ts 95.6% 86.56% 100% 95%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/OpenHandler.ts 97.14% 86.84% 100% 97.14%
toolbox/fdc3-for-web/fdc3-web-impl/src/handlers/support.ts 100% 100% 100% 100%

This comment was marked as outdated.

toolbox/fdc3-for-web/demo/src/client/tsconfig.json.unused Outdated Show resolved Hide resolved
And "App1/a1" is opened with connection id "a1"
And "listenerApp/b1" is opened with connection id "b1"
And "listenerApp/b1" registers an intent listener for "returnBook"
# Scenario: Context Not Handled By App
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines should be deleted.

Comment on lines 119 to 123
# Scenario: Raising An Invalid Intent (non existent intent but valid app)
# When "App1/a1" raises an intent for "nonExistentIntent" with contextType "fdc3.book" on app "listenerApp/b1"
# Then messaging will have outgoing posts
# | msg.payload.error | msg.type |
# | NoAppsFound | raiseIntentResponse |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Scenario: Raising An Invalid Intent (non existent intent but valid app)
# When "App1/a1" raises an intent for "nonExistentIntent" with contextType "fdc3.book" on app "listenerApp/b1"
# Then messaging will have outgoing posts
# | msg.payload.error | msg.type |
# | NoAppsFound | raiseIntentResponse |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? What does this file accomplish for the repo?

packages/fdc3-standard/src/api/Types.ts Outdated Show resolved Hide resolved
packages/fdc3-standard/src/ui/IntentResolver.ts Outdated Show resolved Hide resolved
packages/fdc3-standard/test/ContextTypes.test.ts Outdated Show resolved Hide resolved
packages/fdc3/src/index.ts Outdated Show resolved Hide resolved
packages/testing/src/agent/index.ts Outdated Show resolved Hide resolved
@robmoffat robmoffat changed the title FDC3 For Web Browsers Implementation DO NOT MERGE FDC3 For Web Browsers Implementation DO NOT MERGE OR REVIEW Nov 8, 2024
@robmoffat

This comment was marked as outdated.

This comment was marked as outdated.

@kriswest

This comment was marked as outdated.

This comment was marked as outdated.

@robmoffat

This comment was marked as outdated.

@robmoffat

This comment was marked as outdated.

@kriswest
Copy link
Contributor

kriswest commented Nov 8, 2024

But yes I agree - since this is the implementation of #1297 we can't close that until this is done.

At least it's helping me persuade myself to buy a bigger laptop (rendering the diff takes some doing) ;-)

It's also a huge contribution of work to the standard which will have a massive positive impact on it if you/we pull it off. Looking forward to helping get that done.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link

github-actions bot commented Nov 8, 2024

420 passed

3 similar comments
Copy link

github-actions bot commented Nov 8, 2024

420 passed

Copy link

github-actions bot commented Nov 8, 2024

420 passed

Copy link

github-actions bot commented Nov 8, 2024

420 passed

@robmoffat
Copy link
Member Author

Preview here: https://deploy-preview-1309--fdc3.netlify.app

This comment was marked as outdated.

This comment was marked as outdated.

Copy link

504 passed

@robmoffat robmoffat requested review from julianna-ciq, a team and novavi January 29, 2025 11:51
kriswest
kriswest previously approved these changes Jan 29, 2025
Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've spent an enormous amount of time with this PR and the changes it makes to the repository, new code implemented, documentation improvments etc. and am satisfied that it LGTM!

Copy link

504 passed

@kriswest kriswest self-requested a review January 29, 2025 13:18
Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM again (after fixing fdc3-workbench linter config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment