This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
feat(proxy): demo warp based REST API endpoints #250
Closed
Closed
Changes from 70 commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
fd37997
Bump proxy dependencies
xla 633ba40
Attempt first end-to-end draft
xla aa843ef
Move serialisation to http module
xla 20f9943
Merge branch 'master' into xla/220-warp-implementation
xla 7b45e45
Explore json response assertions
xla a195ce7
Pass state
xla ef919df
Add docs
xla da71cc0
Move project endpoints into own module
xla 695b7c9
Flesh out error responses
xla b9ffe18
Clean up
xla 1f78617
Show case create endpoint
xla ac73fe1
Implement project registration
xla dcad433
Merge branch 'master' into xla/220-warp-implementation
xla 2546e50
Test register
xla 41ec0fa
Implement list endpoint
xla b7e9d0d
Simplify test assertions
xla ee5fccf
Fix reference
xla 7a02e2f
Merge branch 'master' into xla/220-warp-implementation
xla 87ab5a7
Use String in error fields
xla 02c8c22
Remove explicit path end
xla dc6a174
Strings are strings are stirngs
xla 76b1737
Use stronger Url type in the core
xla e4f9a4c
Merge branch 'master' into xla/220-warp-implementation
xla b947b6a
Wire the api in main
xla c754fbf
Use 8080
xla 6e21def
Implement notification endpoint
xla e0a14a8
Wire up some rudimental logging
xla 6bc54c5
chore: document REST API
garbados db653de
Explore mildly how ts state management could look like
xla 0b84ddb
Merge branch 'master' into xla/220-warp-implementation
xla 1f398bb
Merge branch 'xla/220-warp-implementation' into xla/220-meditations-o…
xla 52f45f7
projects store
sarahscott a6a6bf1
messages defined outside of event
sarahscott e667f13
remote data type
sarahscott 238b611
simplify access to readable store
sarahscott fb9f3e9
modifications to RemoteDataStore
sarahscott fa8e53c
remove stray TODOs
sarahscott c7c205f
add another todo for myself
sarahscott 11cd5f7
added more todos
sarahscott 9322187
clean up RemoteDataStore
sarahscott bbd09ea
Merge branch 'master' into xla/220-warp-implementation
xla 5ee5a4e
Enable identities
xla 4b814ab
Clean up
xla 2f24ac7
Add missing docs
xla ce15339
Add transaction listing
xla 4ef7506
Add missing docs
xla a6703e1
Simplify API
xla d21b9a1
Merge branch 'master' into xla/220-warp-implementation
xla b437207
Set up linting for ts
xla e3d5ffe
Improve API access
xla ea0317b
Set cypress cache directory
xla be63d25
Attempt to fix CI
rudolfs 53769de
Revert "Attempt to fix CI"
rudolfs 9413bcd
Simplify event handling
xla cc5bbe4
Make event handling sound
xla daa7ccd
Pass through project stats
xla 437fc4d
Integrate OpenAPI documentation
xla 741d98e
Minimize docs clutter
xla fdb953a
Merge branch 'master' into xla/220-warp-implementation
xla 1ec2631
Expose GraphQL and REST API together
xla 54b4455
Merge branch 'master' into xla/220-warp-implementation
xla 4330574
Fix tests
xla 3948265
sourceBrowserStore & parameterized FileSource
sarahscott 500052a
simplify RevisionSelector
sarahscott 751e88e
update revision event
sarahscott 9a97fa7
simplifies FileList
sarahscott 351fc9a
update source path
sarahscott cf6c842
Implement first source browsing endpoint
xla ab3f0ed
Use string enum for object type documentation
xla ca4423f
Adjust types to match proxy
xla 06991c6
Make prettier check happy
rudolfs cece03b
Correct tye missmatch
xla 88e5854
Fix field
xla 17d6009
Implement commit endpoint
xla 9dd2b79
Implement tree endpoint
xla d381d07
Implement branches endpoint
xla 63d64e9
Implement tags endpoint
xla df138a0
Fix docs
xla 07c8538
Complete first circle of source browsing
xla ebcc13b
blob name and revision event fix
sarahscott f6c6fef
Merge branch 'master' into xla/220-warp-implementation
xla 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
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 |
---|---|---|
|
@@ -10,3 +10,5 @@ cypress/fixtures/example.json | |
proxy/target | ||
proxy/**/*.rs.bk | ||
schema.gql | ||
ui/src/*.js | ||
ui/src/*.js.map |
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 |
---|---|---|
|
@@ -45,6 +45,8 @@ | |
"@babel/node": "^7.8.4", | ||
"@babel/plugin-transform-runtime": "^7.8.3", | ||
"@babel/preset-env": "^7.8.6", | ||
"@typescript-eslint/eslint-plugin": "^2.27.0", | ||
"@typescript-eslint/parser": "^2.27.0", | ||
"apollo": "^2.24.0", | ||
"babel-eslint": "^10.1.0", | ||
"chokidar": "^3.3.1", | ||
|
@@ -67,15 +69,17 @@ | |
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-svelte": "^5.1.1", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"sirv-cli": "^0.4.5", | ||
"standard-version": "^7.1.0", | ||
"svelte": "^3.20.1", | ||
"svelte-click-outside": "https://github.com/radicle-dev/svelte-click-outside#10e47e6359f943d45b72c2f3fc7ccc8036b60fac", | ||
"svelte-spa-router": "^2.1.0", | ||
"typescript": "3.8.3", | ||
"wait-on": "^4.0.1" | ||
}, | ||
"scripts": { | ||
"start": "run-p --race svelte:watch proxy:start graphiql:serve electron:start", | ||
"start": "run-p --race svelte:watch proxy:start:test graphiql:serve electron:start", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this will be reverted before merge? |
||
"start:test": "run-p --race svelte:watch proxy:start:test electron:start", | ||
"test": "TZ='UTC' run-p --race proxy:start:test test:run", | ||
"test:debug": "TZ='UTC' run-p --race svelte:watch proxy:start:test cypress:open", | ||
|
@@ -87,7 +91,7 @@ | |
"svelte:watch": "yarn svelte:clean && rollup -c -w", | ||
"proxy:build": "cd proxy && cargo build --all-features --all-targets", | ||
"proxy:build:release": "cd proxy && cargo build --release --all-features --all-targets", | ||
"proxy:start": "cd proxy && cargo run --release -- --registry=emulator", | ||
"proxy:start": "cd proxy && cargo run -- --registry=emulator", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
"proxy:start:test": "cd proxy && cargo run -- --registry=emulator --test", | ||
"graphiql": "open http://localhost:5000", | ||
"graphiql:serve": "yarn sirv ./graphiql", | ||
|
@@ -101,7 +105,7 @@ | |
"prettier": "prettier \"**/*.@(js|json|svelte|css|html)\" --ignore-path .gitignore", | ||
"prettier:check": "yarn prettier --check", | ||
"prettier:write": "yarn prettier --write", | ||
"lint": "eslint . --ignore-path .gitignore --ext .js,.svelte" | ||
"lint": "eslint . --ignore-path .gitignore --ext js,.svelte,.ts" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "js" vs ".js" a typo here? |
||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.8.4", | ||
|
@@ -132,6 +136,9 @@ | |
"*.svelte": [ | ||
"prettier --plugin-search-dir=. --write", | ||
"eslint --fix" | ||
], | ||
"*.ts": [ | ||
"eslint --fix" | ||
] | ||
} | ||
} |
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,193 @@ | ||
# Radicle Proxy REST API | ||
|
||
## Routes | ||
|
||
All routes under the REST API respond with JSON and expect request bodies to be encoded as JSON with the header `content-type: application/json` set. | ||
|
||
The examples provided use [curl](https://curl.haxx.se/) and the [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) function available in the JavaScript environments of modern browsers. | ||
|
||
### GET /projects | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably add a |
||
|
||
Retrieve a list of known projects. Returns a list of projects. | ||
|
||
Returns a list of Projects. (See Entities) | ||
|
||
Curl example: | ||
|
||
``` | ||
$ curl http://localhost:8080/api/v1/projects | ||
|
||
[ | ||
{ | ||
"id": "ccb86b0a6860e27d403a09f15ce444c9c6b262dc.git", | ||
"metadata": { | ||
"name": "wow", | ||
"description": "hello", | ||
"default_branch": "master", | ||
"img_url": "https://bovid.space/icons/favicon.ico" | ||
} | ||
} | ||
] | ||
``` | ||
|
||
JavaScript example: | ||
|
||
``` | ||
fetch("http://localhost:8080/api/v1/projects") | ||
.then((response) => { | ||
return response.json() | ||
// [{ "id": "...", "metadata": {...} }] | ||
}) | ||
``` | ||
|
||
### POST /projects | ||
|
||
Add a new project from the filesystem, assigning a librad ID to it. | ||
|
||
Request JSON object: | ||
|
||
- `path`: Path to the project on the filesystem, relative to the proxy's working directory. | ||
- `metadata`: An object containing metadata about the project. | ||
- `metadata.name`: The given name of the project. | ||
- `metadata.description`: The given description of the project. | ||
- `metadata.default_branch`: The default branch of the git project, ex: `master`. | ||
- `metadata.img_url`: A URL to the image icon used for the project. | ||
|
||
Returns a Project. (See Entities). | ||
|
||
Status codes: | ||
|
||
- [201 Created](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2): Project assigned a librad ID. | ||
- [400 Bad Request](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1): The project is already known to the proxy. | ||
|
||
Curl example: | ||
|
||
``` | ||
$ curl -v -X POST -H 'content-type: application/json' http://localhost:8080/api/v1/projects -d '{"path":"..", "metadata":{"name":"radicle-upstream-proxy", "description":"hello world", "img_url":"http://bovid.space/favicon.ico", "default_branch": "master"}}' | ||
|
||
{ | ||
"id": "1a7f9a6e1883fc5781f3b1f8dccf21df04e06f11.git", | ||
"metadata": { | ||
"name": "who", | ||
"description": "hello", | ||
"default_branch": "master", | ||
"img_url": "http://bovid.space/favicon.ico" | ||
} | ||
} | ||
``` | ||
|
||
JavaScript example: | ||
|
||
``` | ||
fetch("http://localhost:8080/api/v1/projects", { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
path: "/home/$USER/code/radicle-upstream", | ||
metadata: { | ||
name: "radicle-upstream", | ||
description: "Upstream is a cross-platform desktop client for the radicle code collaboration and registry protocols.", | ||
default_branch: "master", | ||
img_url: "https://..." | ||
} | ||
}) | ||
}) | ||
.then((response) => { | ||
return response.json() | ||
// { "id": "...", "metadata": {...} } | ||
}) | ||
``` | ||
|
||
### GET /projects/<id> | ||
|
||
Retrieve information about a particular project by its librad ID. | ||
|
||
Returns a Project. (See Entities). | ||
|
||
Curl example: | ||
|
||
``` | ||
$ curl http://localhost:8080/api/v1/projects/da465d3457cc48968d78f66aadd01f8504c363a2.git | ||
|
||
{"id":"da465d3457cc48968d78f66aadd01f8504c363a2.git","metadata":{"name":"radicle-upstream-proxy","description":"hello world","default_branch":"master","img_url":"http://bovid.space/favicon.ico"}} | ||
``` | ||
|
||
### POST /projects/register | ||
|
||
Register a project on the Radicle Registry. | ||
|
||
Request JSON object: | ||
|
||
- `org_id`: ID of the organization under which the project will be registered. | ||
- `project_name`: Name of the project to use in the registry. | ||
- `maybe_coco_id`: Optional librad ID for the project, used for mutual attestation. | ||
|
||
Response JSON object: | ||
|
||
- `id`: Abridged hexadecimal ID of this transaction on the registry. | ||
- `messages[]`: Array of messages from the registry. | ||
- `messages[].ProjectRegistration`: Information about the project registration. | ||
- `messages[].ProjectRegistration.org_id`: Name of the organization with which the project is registered. | ||
- `messages[].ProjectRegistration.project_name`: Name of the registered project. | ||
- `state`: Information about the state of the transaction. | ||
- `state.type`: A string indicating the state of the transaction. Currently will only ever be `TransactionApplied`. | ||
- `state.block_hash`: The hash of the block the transaction is included in. | ||
- `timestamp`: An object indicating when this transaction was applied. | ||
- `timestamp.secs_since_epoch`: Seconds since epoch to the moment this transaction was applied. | ||
- `timestamp.nanos_since_epoch`: Nanoseconds since epoch to the second this transaction was applied. | ||
|
||
Curl example: | ||
|
||
``` | ||
$ curl -v -X POST -H 'content-type: application/json' http://localhost:8080/api/v1/projects/register -d '{"org_id": "radicle", "project_name": "radicle-upstream"}' | ||
|
||
{ | ||
"id": "0x47d8…3fcb", | ||
"messages": [ | ||
{ | ||
"ProjectRegistration": { | ||
"org_id": "abcdef", | ||
"project_name": "cool-kids-club" | ||
} | ||
} | ||
], | ||
"state": { | ||
"type": "TransactionApplied", | ||
"block_hash": "0x0000…0000" | ||
}, | ||
"timestamp": { | ||
"secs_since_epoch": 1585616602, | ||
"nanos_since_epoch": 216308544 | ||
} | ||
} | ||
``` | ||
|
||
JavaScript example: | ||
|
||
``` | ||
fetch("http://localhost:8080/v1/projects/register", { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
org_id: "radicle", | ||
project_name: "radicle-upstream" | ||
}) | ||
}) | ||
``` | ||
|
||
## Entities | ||
|
||
The API returns some common objects representing entities in the domain. | ||
|
||
### Project | ||
|
||
- `id`: Librad ID of the project. | ||
- `metadata`: An object containing metadata about the project. | ||
- `metadata.name`: The given name of the project. | ||
- `metadata.description`: The given description of the project. | ||
- `metadata.default_branch`: The default branch of the git project, ex: `master`. | ||
- `metadata.img_url`: A URL to the image icon used for the project. |
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.
I think this and L24 didn't make any difference to the CI build stability and can be removed again.