-
Notifications
You must be signed in to change notification settings - Fork 204
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
feat(action-menu)!: move to separate package #1049
Merged
TimoGlastra
merged 3 commits into
openwallet-foundation:0.3.0-pre
from
2060-io:feat/extract-action-menu-module
Oct 12, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<p align="center"> | ||
<br /> | ||
<img | ||
alt="Hyperledger Aries logo" | ||
src="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/aa31131825e3331dc93694bc58414d955dcb1129/images/aries-logo.png" | ||
height="250px" | ||
/> | ||
</p> | ||
<h1 align="center"><b>Aries Framework JavaScript Action Menu Plugin</b></h1> | ||
<p align="center"> | ||
<a | ||
href="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/main/LICENSE" | ||
><img | ||
alt="License" | ||
src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" | ||
/></a> | ||
<a href="https://www.typescriptlang.org/" | ||
><img | ||
alt="typescript" | ||
src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg" | ||
/></a> | ||
<a href="https://www.npmjs.com/package/@aries-framework/action-menu" | ||
><img | ||
alt="@aries-framework/action-menu version" | ||
src="https://img.shields.io/npm/v/@aries-framework/action-menu" | ||
/></a> | ||
|
||
</p> | ||
<br /> | ||
|
||
Action Menu plugin for [Aries Framework JavaScript](https://github.com/hyperledger/aries-framework-javascript.git). Implements [Aries RFC 0509](https://github.com/hyperledger/aries-rfcs/blob/1795d5c2d36f664f88f5e8045042ace8e573808c/features/0509-action-menu/README.md). | ||
|
||
### Installation | ||
|
||
Make sure you have set up the correct version of Aries Framework JavaScript according to the AFJ repository. To find out which version of AFJ you need to have installed you can run the following command. This will list the required peer dependency for `@aries-framework/core`. | ||
|
||
```sh | ||
npm info "@aries-framework/action-menu" peerDependencies | ||
``` | ||
|
||
Then add the action-menu plugin to your project. | ||
|
||
```sh | ||
yarn add @aries-framework/action-menu | ||
``` | ||
|
||
### Quick start | ||
|
||
In order for this plugin to work, we have to inject it into the agent to access agent functionality. See the example for more information. | ||
|
||
### Example of usage | ||
|
||
```ts | ||
import { ActionMenuModule } from '@aries-framework/action-menu' | ||
|
||
const agent = new Agent({ | ||
config: { | ||
/* config */ | ||
}, | ||
dependencies: agentDependencies, | ||
modules: { | ||
actionMenu: new ActionMenuModule(), | ||
/* other custom modules */ | ||
}, | ||
}) | ||
|
||
await agent.initialize() | ||
|
||
// To request root menu to a given connection (menu will be received | ||
// asynchronously in a ActionMenuStateChangedEvent) | ||
await agent.modules.actionMenu.requestMenu({ connectionId }) | ||
|
||
// To select an option from the action menu | ||
await agent.modules.actionMenu.performAction({ | ||
connectionId, | ||
performedAction: { name: 'option-1' }, | ||
}) | ||
``` |
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,13 @@ | ||
import type { Config } from '@jest/types' | ||
|
||
import base from '../../jest.config.base' | ||
|
||
import packageJson from './package.json' | ||
|
||
const config: Config.InitialOptions = { | ||
...base, | ||
name: packageJson.name, | ||
displayName: packageJson.name, | ||
} | ||
|
||
export default config |
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,41 @@ | ||
{ | ||
"name": "@aries-framework/action-menu", | ||
"main": "build/index", | ||
"types": "build/index", | ||
"version": "0.2.4", | ||
"private": true, | ||
"files": [ | ||
"build" | ||
], | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"homepage": "https://github.com/hyperledger/aries-framework-javascript/tree/main/packages/action-menu", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hyperledger/aries-framework-javascript", | ||
"directory": "packages/action-menu" | ||
}, | ||
"scripts": { | ||
"build": "yarn run clean && yarn run compile", | ||
"clean": "rimraf -rf ./build", | ||
"compile": "tsc -p tsconfig.build.json", | ||
"prepublishOnly": "yarn run build", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"rxjs": "^7.2.0", | ||
"class-transformer": "0.5.1", | ||
"class-validator": "0.13.1" | ||
}, | ||
"peerDependencies": { | ||
"@aries-framework/core": "0.2.4" | ||
}, | ||
"devDependencies": { | ||
"@aries-framework/node": "0.2.4", | ||
"reflect-metadata": "^0.1.13", | ||
"rimraf": "~3.0.2", | ||
"typescript": "~4.3.0" | ||
} | ||
} |
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
3 changes: 1 addition & 2 deletions
3
...dules/action-menu/ActionMenuApiOptions.ts → ...s/action-menu/src/ActionMenuApiOptions.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
2 changes: 1 addition & 1 deletion
2
...c/modules/action-menu/ActionMenuEvents.ts → packages/action-menu/src/ActionMenuEvents.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
5 changes: 2 additions & 3 deletions
5
...c/modules/action-menu/ActionMenuModule.ts → packages/action-menu/src/ActionMenuModule.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
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
packages/action-menu/src/__tests__/ActionMenuModule.test.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,43 @@ | ||
import type { DependencyManager, FeatureRegistry } from '@aries-framework/core' | ||
|
||
import { Protocol } from '@aries-framework/core' | ||
|
||
import { | ||
ActionMenuApi, | ||
ActionMenuModule, | ||
ActionMenuRepository, | ||
ActionMenuRole, | ||
ActionMenuService, | ||
} from '@aries-framework/action-menu' | ||
|
||
const dependencyManager = { | ||
registerInstance: jest.fn(), | ||
registerSingleton: jest.fn(), | ||
registerContextScoped: jest.fn(), | ||
} as unknown as DependencyManager | ||
|
||
const featureRegistry = { | ||
register: jest.fn(), | ||
} as unknown as FeatureRegistry | ||
|
||
describe('ActionMenuModule', () => { | ||
test('registers dependencies on the dependency manager', () => { | ||
const actionMenuModule = new ActionMenuModule() | ||
actionMenuModule.register(dependencyManager, featureRegistry) | ||
|
||
expect(dependencyManager.registerContextScoped).toHaveBeenCalledTimes(1) | ||
expect(dependencyManager.registerContextScoped).toHaveBeenCalledWith(ActionMenuApi) | ||
|
||
expect(dependencyManager.registerSingleton).toHaveBeenCalledTimes(2) | ||
expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(ActionMenuService) | ||
expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(ActionMenuRepository) | ||
|
||
expect(featureRegistry.register).toHaveBeenCalledTimes(1) | ||
expect(featureRegistry.register).toHaveBeenCalledWith( | ||
new Protocol({ | ||
id: 'https://didcomm.org/action-menu/1.0', | ||
roles: [ActionMenuRole.Requester, ActionMenuRole.Responder], | ||
}) | ||
) | ||
}) | ||
}) |
5 changes: 3 additions & 2 deletions
5
...nu/errors/ActionMenuProblemReportError.ts → ...rc/errors/ActionMenuProblemReportError.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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...andlers/ActionMenuProblemReportHandler.ts → ...andlers/ActionMenuProblemReportHandler.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
2 changes: 1 addition & 1 deletion
2
...ction-menu/handlers/MenuMessageHandler.ts → ...n-menu/src/handlers/MenuMessageHandler.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
2 changes: 1 addition & 1 deletion
2
...enu/handlers/MenuRequestMessageHandler.ts → ...src/handlers/MenuRequestMessageHandler.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
2 changes: 1 addition & 1 deletion
2
...on-menu/handlers/PerformMessageHandler.ts → ...enu/src/handlers/PerformMessageHandler.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
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions
5
...essages/ActionMenuProblemReportMessage.ts → ...essages/ActionMenuProblemReportMessage.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
3 changes: 1 addition & 2 deletions
3
...dules/action-menu/messages/MenuMessage.ts → ...s/action-menu/src/messages/MenuMessage.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
3 changes: 1 addition & 2 deletions
3
...ction-menu/messages/MenuRequestMessage.ts → ...n-menu/src/messages/MenuRequestMessage.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
4 changes: 1 addition & 3 deletions
4
...es/action-menu/messages/PerformMessage.ts → ...ction-menu/src/messages/PerformMessage.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
6 changes: 1 addition & 5 deletions
6
...n-menu/repository/ActionMenuRepository.ts → ...nu/src/repository/ActionMenuRepository.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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...menu/services/ActionMenuServiceOptions.ts → .../src/services/ActionMenuServiceOptions.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
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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as a comment on your work, but we should probably export the dummyModule so other people can get started aswell :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean exactly by this @blu3beri?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a samples/extension-module in AFJ explaining to people on how to create an extension module, the old way. If we update that everyone has a clear example to start modularising other modules and their custom modules that they might use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha! Yes totally agree