-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-menu)!: move to separate package (#1049)
Signed-off-by: Ariel Gentile <[email protected]> BREAKING CHANGE: action-menu module has been removed from the core and moved to a separate package. To integrate it in an Agent instance, it can be injected in constructor like this: ```ts const agent = new Agent({ config: { /* config */ }, dependencies: agentDependencies, modules: { actionMenu: new ActionMenuModule(), /* other custom modules */ } }) ``` Then, module API can be accessed in `agent.modules.actionMenu`.
- Loading branch information
Showing
49 changed files
with
350 additions
and
200 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
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.