Skip to content

Commit

Permalink
feat: implement versioning documentation (#234)
Browse files Browse the repository at this point in the history
<!--
  For Work In Progress Pull Requests, please use the Draft PR feature,
see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for
further details.
  
  For a timely review/response, please avoid force-pushing additional
  commits if your PR already received reviews or comments.
  
Before submitting a Pull Request, please ensure you've done the
following:
- 📖 Read the [Contributing
Guide](https://github.com/uncefact/project-vckit/blob/main/CONTRIBUTING.md).
- 📖 Read the [Code of
Conduct](https://github.com/uncefact/project-vckit/blob/main/CODE_OF_CONDUCT.md).
  - 👷‍♀️ Create small PRs. In most cases, this will be possible.
  - ✅ Provide tests for your changes.
- 📝 Use descriptive commit messages following [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/).
- 📗 Update any related documentation and include any relevant
screenshots.
-->

## What type of PR is this? (check all applicable)

- [x] 🍕 Feature
- [ ] 🐛 Bug Fix
- [x] 📝 Documentation Update
- [ ] 🎨 Style
- [ ] 🧑‍💻 Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore (Release)
- [ ] ⏩ Revert

## Description

<!-- 
Please do not leave this blank 
This PR [adds/removes/fixes/replaces] the [feature/bug/etc]. 
-->

## Related Tickets & Documents
<!-- 
Please use this format link issue numbers: Fixes #123

https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Mobile & Desktop Screenshots/Recordings

<!-- Visual changes require screenshots -->


## Added tests?

- [ ] 👍 yes
- [x] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

## Added to documentation?

- [ ] 📜 README.md
- [x] 📓 [vc-kit doc site](https://uncefact.github.io/vckit/)
- [ ] 📕 storybook
- [ ] 🙅 no documentation needed

## [optional] Are there any post-deployment tasks we need to perform?


<!-- note: PRs with deleted sections will be marked invalid -->
  • Loading branch information
ldhyen99 authored Dec 24, 2024
1 parent 2b517ad commit a019686
Show file tree
Hide file tree
Showing 42 changed files with 2,576 additions and 6 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,20 @@ docker-compose up
```

This command will build the Docker images (if not already built) and start the containers defined in the `docker-compose.yaml` file. The VCkit API will be accessible at `http://localhost:3332`.

## Documentation Versioning

The project uses Docusaurus for documentation management. Documentation versions are managed through a release script and automated pipeline.

### Release Script

The `scripts/release-doc.js` script automates the process of creating new documentation versions:

- Reads the documentation version from `version.json`
- Creates Docusaurus version using `docVersion` value from `version.json` file
To manually create a new documentation version:

```bash
# Run the release script
pnpm release:doc
```
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ This key type is an X25519 key.
The result for example:

> X25519 raw private key (hex encoded):
4ae7b7d37d82998a759c5d6241e602de5784a05c11be3812c3d31cb854e9be21
You can use this key with @veramo/kms-local#SecretBox or replace the default agent.yml 'dbEncryptionKey' constant
- 4ae7b7d37d82998a759c5d6241e602de5784a05c11be3812c3d31cb854e9be21
- You can use this key with @veramo/kms-local#SecretBox or replace the default agent.yml 'dbEncryptionKey' constant

- Update the `dbEncryptionKey` in the `agent.yml` file with the generated key.

Expand All @@ -95,13 +95,13 @@ You can use this key with @veramo/kms-local#SecretBox or replace the default age
```
> **_WARNING_**:
The `dbEncryptionKey` is a sensitive value. Do not share it with anyone. If you lose the key, you will not be able to decrypt the data stored in the database.
In a production environment, please do not use the default key in a production environment.
- The `dbEncryptionKey` is a sensitive value. Do not share it with anyone. If you lose the key, you will not be able to decrypt the data stored in the database.
- In a production environment, please do not use the default key in a production environment.

## Start the local server

```bash
pnpm vckit server
```

Now you can check the api documentation at [http://localhost:3332/api-docs](http://localhost:3332/api-docs)
Now you can check the api documentation at [http://localhost:3332/api-docs](http://localhost:3332/api-docs)
3 changes: 3 additions & 0 deletions documentation/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const config = {
position: 'left',
label: 'Documentation',
},
{
type: 'docsVersionDropdown',
},
// {
// type: 'docSidebar',
// sidebarId: 'documentSidebar',
Expand Down
3 changes: 3 additions & 0 deletions documentation/versioned_docs/version-1.0.0/_disclaimer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:::info
Please note that this content is under development and is not ready for implementation. This status message will be updated as content development progresses.
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Agent Configuration",
"position": 3,
"link": {
"type": "generated-index",
"description": "This documentation is a guide of how to config an VCkit agent."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import Disclaimer from './../\_disclaimer.mdx';

# Config Agent File

<Disclaimer />

This guide explains the structure and options available within the agent config file. Use cases illustrating how to customise the config file for different scenarios are included.

## Diagram

The diagram belows describes the structure of an agent file

![agent file diagram](/img/agent-file.svg)

:::tip
For more information about yml configuration, you can see [here](https://veramo.io/docs/veramo_agent/configuration_internals)
:::

## Constants

This section is to declare all the constants of the agent.

```yml
constants:
baseUrl: <BASE URL>
port: <CUSTOM PORT>
dbEncryptionKey: <SECRET KEY>
databaseFile: <DATA BASE FILE>
methods:
- <PLUGIN FUNCTIONS>
```
- `baseUrl`: This specifies the base URL for the application or service.
- `port`: This specifies the port number on which the application will listen for incoming connections.
- `dbEncryptionKey`: This field contains a cryptographic key used for encrypting data in the database. It's a hexadecimal string representing the encryption key. Run this command `veramo config gen-key` to generate a key.
- `databaseFile`: This specifies the path to the SQLite database file.
- `methods`: This specifies the functions that are exposed by the plugins integrated within the agent

## **`$require` syntax**

Example:
`$require: '@veramo/data-store?t=object#migrations'`
- `@veramo/data-store` - Module name
- `t=object` - Optional. Type can be `function`, `object`, `class`. Default is `class`
- `#migrations` - Imported symbol name

## Database connection

This section is to declare all of the database connections that are used by the agent plugins. Below is a declaration of a database connection.

```yml
dbConnection: //this is name of the connection
$require: typeorm#DataSource
$args:
- type: sqlite
database:
$ref: /constants/databaseFile
synchronize: false
migrationsRun: true
migrations:
$require: '@veramo/data-store?t=object#migrations'
logging: false
entities:
$require: '@veramo/data-store?t=object#Entities'
```

- `dbConnection`: This is the name of the connection. It's a label that identifies this specific database connection configuration.
- `$require`: This indicates that a specific module or package is required to handle this configuration. In this case, it's indicating that the DataSource type from the typeorm package is required.
- `$args`: This specifies the arguments to be passed to the DataSource constructor.

- `type`: Specifies the type of database to be used. You can use whatever type of database as long as it's supported by TypeOrm Datasource.
- `database`: This field specifies the path to the SQLite database file.
- `$ref`: This refers to a constant defined elsewhere in the configuration.
- `synchronize`: Determines whether TypeORM should automatically synchronize the database schema.
- `migrationsRun`: Specifies whether TypeORM should run migrations automatically. It's set to true, indicating that migrations should be executed.
- `migrations`: Specifies the location of migration files.
- `$require`: This indicates that migration files are required from a specific module. It's pointing to the migrations provided by the **@veramo/data-store package**.
- `logging`: Specifies whether TypeORM should log SQL queries. It's set to false to disable logging.
- `entities`: Specifies the entities (database tables) managed by TypeORM.

- `$require`: This indicates that entities are required from a specific module. It's pointing to the entities provided by the **@veramo/data-store package**.

## Server configuration

This section is to config the server.

```yml
server:
baseUrl:
$ref: /constants/baseUrl
port:
$ref: /constants/port
use:
- - $require: '@vckit/remote-server?t=function#RequestWithAgentRouter'
$args:
- agent:
$ref: /agent
```

1. `baseUrl` and `port`:
- These fields define the base URL and port number where the server will be hosted. However, instead of directly providing values, they reference values from the constants section. This ensures that the server's base URL and port remain consistent and can be easily modified in one central place.
2. `use`:
This section configures middleware for the server's request handling. **RequestWithAgentRouter**: This middleware is being utilized, which seems to be custom functionality provided by the @vckit/remote-server package. It appears to add information about an agent to incoming requests.

- `$require`: Specifies the module or package required to handle this middleware.
- `$args`: Specifies the arguments to be passed to the middleware. In this case, it's using agent.
- `agent`: This argument is being provided to the middleware. It references a value from elsewhere in the configuration, specifically from `/agent`. This likely injects agent-related information or functionality into incoming requests, enhancing their handling within the server.

### Authentication middleware plugin

This section is to declare the middleware for the server. The authentication middleware plugin is used to check the incoming request for a valid token.

```yml
server:
baseUrl:
$ref: /constants/baseUrl
port:
$ref: /constants/port
use:
- - $require: '@vckit/remote-server?t=function#RequestWithAgentRouter'
$args:
- agent:
$ref: /agent
- - /agent
# Authentication middleware
- $require: '@vckit/remote-server?t=function#apiKeyAuth'
$args:
- apiKey: <your_api_key>
```

The authentication middleware plugin is added by attaching the `apiKeyAuth` function to the route of the server with the `apiKey` argument. The `apiKey` argument is important to authenticate the incoming request, it also be used on Explorer to authenticate the agent.

## Plugins configuration

Functionality in VCkit is added to the agent through a plugin system. Each plugin will have different arguments and required packages. However, this is basically how to declare a plugin.

**Example**

```yml
renderer:
$require: '<required packages>'
$args:
- exampleArg: <field value>
```

- `renderer`: This is the plugin's name.
- `$require`: Specifies the module or package required to handle functionality.
- `$args`: Specifies the arguments to be passed to the module.

## Agent configuration

```yml
# Agent
agent:
$require: '@veramo/core#Agent'
$args:
- schemaValidation: false
plugins:
- $ref: <path to the plugin defined in the agent file>
- $require: '<required package>'
$args:
- $ref: <path to the constant>
```

- The configuration is under the `agent` key, indicating settings specific to the agent.
- `$require`: Specifies the module or package required to instantiate the agent. In this case, it's @veramo/core#Agent, which is responsible for creating and managing the agent.
- `$args`: Specifies the arguments to be passed to the agent constructor.
- `schemaValidation`: A boolean flag indicating whether schema validation should be enabled. Here, it's set to `false`, meaning schema validation is disabled.
- `plugins`: Specifies the plugins to be loaded by the agent.
- `$ref`: This references a plugin configuration defined elsewhere in the agent file.
- `$require`: Specifies the module or package required by the plugin
- `$args`: (optional) Specifies arguments to be passed to the plugin constructor.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Getting Started",
"position": 2,
"link": {
"type": "generated-index",
"description": "Let's start explore the VCkit"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "API Server",
"position": 3,
"link": {
"type": "generated-index",
"description": "This API Server Started Guide covers installation, initial setup, and basic operations/functionality. You can follow steps by steps to get started with API Server."
}
}
Loading

0 comments on commit a019686

Please sign in to comment.