forked from finos/FDC3
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from finos-labs/robs-branch
First intent tests working
- Loading branch information
Showing
174 changed files
with
14,468 additions
and
2,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
packageExtensions: | ||
"@cucumber/cucumber@*": | ||
dependencies: | ||
"ts-node": "*" | ||
"@cucumber/pretty-formatter": "*" | ||
|
||
yarnPath: .yarn/releases/yarn-4.0.2.cjs | ||
"@cucumber/pretty-formatter": "*" | ||
ts-node: "*" | ||
vite-express@*: | ||
dependencies: | ||
express: "*" | ||
vite: "*" | ||
|
||
yarnPath: .yarn/releases/yarn-4.1.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"name": "client", | ||
"main": "src/index.ts", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"build": "tsc -b" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/client/src/intent-resolution/DesktopAgentIntentResolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { AppIntent, IntentResult } from "@finos/fdc3"; | ||
import { Messaging } from "da-proxy"; | ||
import { IntentResolver, SingleAppIntent, IntentResolutionChoiceAgentResponse } from "fdc3-common"; | ||
|
||
/** | ||
* Works with the desktop agent to provide a resolution to the intent choices. | ||
*/ | ||
export class DesktopAgentIntentResolver implements IntentResolver { | ||
|
||
private readonly m: Messaging | ||
private readonly uri: string | ||
private container: HTMLDivElement | undefined = undefined | ||
|
||
constructor(m: Messaging, uri: string) { | ||
this.m = m | ||
this.uri = uri | ||
} | ||
|
||
async intentChosen(ir: IntentResult): Promise<IntentResult> { | ||
this.removeFrame() | ||
return ir | ||
} | ||
|
||
async chooseIntent(appIntents: AppIntent[]): Promise<SingleAppIntent> { | ||
this.openFrame(appIntents) | ||
|
||
const choice = await this.m.waitFor<IntentResolutionChoiceAgentResponse>(m => m.type == 'intentResolutionChoice') | ||
|
||
this.removeFrame() | ||
|
||
return choice.payload | ||
} | ||
|
||
removeFrame() { | ||
if (this.container) { | ||
document.body.removeChild(this.container) | ||
this.container = undefined | ||
} | ||
} | ||
|
||
buildUrl(appIntents: AppIntent[]): string { | ||
return this.uri + "?intentDetails=" + encodeURIComponent(JSON.stringify(appIntents)) + | ||
"&source=" + encodeURIComponent(JSON.stringify(this.m.getSource())) | ||
} | ||
|
||
openFrame(appIntents: AppIntent[]): void { | ||
this.removeFrame() | ||
|
||
this.container = document.createElement("div") | ||
document.body.appendChild(this.container) | ||
this.container.style.position = "fixed" | ||
this.container.style.zIndex = "1000" | ||
this.container.style.left = "10%" | ||
this.container.style.top = "10%" | ||
this.container.style.right = "10%" | ||
this.container.style.bottom = "10%" | ||
|
||
var ifrm = document.createElement("iframe") | ||
ifrm.setAttribute("src", this.buildUrl(appIntents)) | ||
ifrm.setAttribute("name", "FDC3 Communications") | ||
ifrm.style.width = "100%" | ||
ifrm.style.height = "100%" | ||
this.container.appendChild(ifrm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.