-
-
Notifications
You must be signed in to change notification settings - Fork 99
feat: Add Accord Project APAP integration with configurable server URL #395
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
Open
niallroche
wants to merge
2
commits into
accordproject:main
Choose a base branch
from
niallroche:feature/apap-upload-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 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 hidden or 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,161 @@ | ||
# API Upload Features | ||
|
||
This document describes the new API upload functionality added to the Accord Protocol Template Playground. | ||
|
||
## Overview | ||
|
||
The template playground now includes comprehensive support for uploading templates and creating agreements using the Accord Protocol API format as defined in the [OpenAPI specification](https://raw.githubusercontent.com/accordproject/apap/refs/heads/main/openapi.json). | ||
|
||
## New Components | ||
|
||
### 1. Template Metadata Editor | ||
|
||
**Location**: `src/editors/editorsContainer/TemplateMetadata.tsx` | ||
|
||
A form-based editor that allows users to configure all template metadata fields required by the API: | ||
|
||
- **Basic Properties**: | ||
- Author | ||
- Display Name | ||
- Version | ||
- Description | ||
- License (dropdown with common licenses) | ||
- Keywords (tag-based input) | ||
|
||
- **Runtime Metadata**: | ||
- Runtime (TypeScript/JavaScript/ES2015) | ||
- Template Type (Clause/Contract/Template) | ||
- Cicero Version | ||
|
||
### 2. Template Logic Editor | ||
|
||
**Location**: `src/editors/editorsContainer/TemplateLogic.tsx` | ||
|
||
A large text area editor for writing TypeScript/JavaScript logic code with: | ||
- Syntax highlighting | ||
- Undo/Redo functionality | ||
- Monospace font for code readability | ||
|
||
### 3. API Upload Component | ||
|
||
**Location**: `src/components/ApiUpload.tsx` | ||
|
||
A comprehensive upload interface that provides: | ||
|
||
- **API Configuration**: Configurable API base URL | ||
- **Template Upload**: Upload template to API with validation | ||
- **Agreement Creation**: Create agreements from uploaded templates | ||
- **Template Download**: Download template as JSON file | ||
- **Preview Modal**: View formatted template JSON before upload | ||
|
||
## API Integration | ||
|
||
### Template Format | ||
|
||
The system automatically formats templates according to the Accord Protocol API specification: | ||
|
||
```json | ||
{ | ||
"uri": "resource:[email protected]#template-name", | ||
"author": "Author Name", | ||
"displayName": "Template Display Name", | ||
"version": "1.0.0", | ||
"description": "Template description", | ||
"license": "Apache-2", | ||
"keywords": ["keyword1", "keyword2"], | ||
"metadata": { | ||
"$class": "[email protected]", | ||
"runtime": "typescript", | ||
"template": "clause", | ||
"cicero": "0.25.x" | ||
}, | ||
"logo": null, | ||
"templateModel": { | ||
"$class": "[email protected]", | ||
"typeName": "templatename", | ||
"model": { | ||
"$class": "[email protected]", | ||
"ctoFiles": [ | ||
{ | ||
"contents": "// Concerto model content", | ||
"filename": "model.cto" | ||
} | ||
] | ||
} | ||
}, | ||
"text": { | ||
"$class": "[email protected]", | ||
"templateText": "TemplateMark content" | ||
}, | ||
"logic": "// Template logic code", | ||
"sampleRequest": null | ||
} | ||
``` | ||
|
||
### API Endpoints | ||
|
||
The system integrates with the following API endpoints: | ||
|
||
- `POST /templates` - Upload template | ||
- `POST /agreements` - Create agreement from template | ||
- `GET /templates` - List templates | ||
- `GET /agreements` - List agreements | ||
|
||
## Usage | ||
|
||
### 1. Configure Template Metadata | ||
|
||
1. Open the "Template Metadata" panel | ||
2. Fill in required fields (Author and Display Name are mandatory) | ||
3. Configure runtime settings as needed | ||
|
||
### 2. Write Template Logic (Optional) | ||
|
||
1. Open the "Template Logic" panel | ||
2. Write TypeScript/JavaScript code for template execution | ||
3. Use undo/redo for code editing | ||
|
||
### 3. Upload to API | ||
|
||
1. Open the "API Upload" panel | ||
2. Configure the API base URL | ||
3. Click "Upload Template to API" | ||
4. Review the generated JSON in the preview modal | ||
5. Optionally create agreements from the uploaded template | ||
|
||
### 4. Download Template | ||
|
||
- Use the "Download Template JSON" button to save the template locally | ||
|
||
## State Management | ||
|
||
The new features are integrated into the existing Zustand store with: | ||
|
||
- `templateMetadata`: Template metadata state | ||
- `templateLogic`: Template logic code | ||
- `setTemplateMetadata()`: Update metadata | ||
- `setTemplateLogic()`: Update logic code | ||
|
||
## Data Persistence | ||
|
||
Template metadata and logic are included in: | ||
- Shareable links (compressed data) | ||
- Sample loading | ||
- State restoration | ||
|
||
## Error Handling | ||
|
||
The system includes comprehensive error handling: | ||
- Validation of required fields | ||
- API error responses | ||
- Network connectivity issues | ||
- JSON parsing errors | ||
|
||
## Future Enhancements | ||
|
||
Potential improvements: | ||
- Template versioning | ||
- Batch upload capabilities | ||
- Template marketplace integration | ||
- Advanced validation rules | ||
- Template testing framework |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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.
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.
This looks like a great feature!
I haven't tested the functionality, but looking at the UI, I have a little suggestion.
Having Template Logic with the other three existing editors makes perfect sense but should we think about some other place for Template Metadata and API Upload features? They could perhaps be popups with their buttons placed somewhere in the "Load Sample" row.