Skip to content

Commit

Permalink
Merge pull request #122 from ember-nexus/github-issue/49
Browse files Browse the repository at this point in the history
GitHub issue/49
  • Loading branch information
Syndesi authored Sep 14, 2023
2 parents a539553 + dfed746 commit d338e6f
Show file tree
Hide file tree
Showing 60 changed files with 933 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ELASTIC_AUTH=ember-nexus-elasticsearch:9200
REDIS_AUTH=tcp://ember-nexus-redis?password=redis-password
RABBITMQ_AUTH=amqp://user:password@ember-nexus-rabbitmq:5672

REFERENCE_DATASET_VERSION=0.0.6
REFERENCE_DATASET_VERSION=0.0.9
1 change: 1 addition & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"default": true,
"MD013": false,
"MD033": false,
"MD038": false,
"MD041": false
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- Add feature test for GET `/token` endpoint
- Add feature test for POST `/token` endpoint
- Add feature test for DELETE `/token` endpoint
### Changed
- Increase reference dataset version to 0.0.8.
- **Switch license to GPL-3.0-only.**

## 0.0.27 - 2023-09-02
Expand Down
60 changes: 41 additions & 19 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,47 @@
- [Passwords, Tokens and Hashing](/security/passwords-tokens-and-hashing)
- [Security Tests](/security/test/general)
- API Endpoints
- Generic Endpoints
- [`GET / -` Get Index](/api-endpoints/get-index)
- [`GET /<uuid> -` Get Element](/api-endpoints/get-element)
- [`GET /<uuid>/parents -` Get Parents](/api-endpoints/get-parents)
- [`GET /<uuid>/children -` Get Children](/api-endpoints/get-children)
- [`GET /<uuid>/related -` Get Related](/api-endpoints/get-related)
- [`POST / -` Create Root Element](/api-endpoints/post-index)
- [`POST /<uuid> -` Create Element](/api-endpoints/post-element)
- [`PUT /<uuid> -` Replace Element](/api-endpoints/put-element)
- [`PATCH /<uuid> -` Update Element](/api-endpoints/patch-element)
- [`DELETE /<uuid> -` Delete Element](/api-endpoints/delete-element)
- [`POST /search -` Search](/api-endpoints/post-search)
- [`GET /instance-configuration -` Get Instance Configuration](/api-endpoints/get-instance-configuration)
- User Endpoints
- [`POST /register -` Register New Account](/api-endpoints/post-register)
- [`POST /sessions -` Create Session](/api-endpoints/post-sessions)
- [`GET /sessions -` Get Sessions](/api-endpoints/get-sessions)
- [`GET /sessions/<uuid> -` Get Specific Session](/api-endpoints/get-specific-session)
- [`DELETE /sessions/<uuid> -` Delete Session](/api-endpoints/delete-session)

- **User Endpoints**
- [<span class="method-post">POST</span>` /register -` Register New Account](/api-endpoints/user/post-register)
- [<span class="method-post">POST</span>` /token -` Create Token](/api-endpoints/user/post-token)
- [<span class="method-get">GET</span>` /token -` Get Token](/api-endpoints/user/get-token)
- [<span class="method-delete">DELETE</span>` /token -` Delete Token](/api-endpoints/user/delete-token)
- **Element Endpoints**
- [<span class="method-get">GET</span>` / -` Get Index](/api-endpoints/element/get-index)
- [<span class="method-get">GET</span>` /<uuid> -` Get Element](/api-endpoints/element/get-element)
- [<span class="method-get">GET</span>` /<uuid>/parents -` Get Parents](/api-endpoints/element/get-parents)
- [<span class="method-get">GET</span>` /<uuid>/children -` Get Children](/api-endpoints/element/get-children)
- [<span class="method-get">GET</span>` /<uuid>/related -` Get Related](/api-endpoints/element/get-related)
- [<span class="method-post">POST</span>` / -` Create Root Element](/api-endpoints/element/post-index)
- [<span class="method-post">POST</span>` /<uuid> -` Create Element](/api-endpoints/element/post-element)
- [<span class="method-put">PUT</span>` /<uuid> -` Replace Element](/api-endpoints/element/put-element)
- [<span class="method-patch">PATCH</span>` /<uuid> -` Update Element](/api-endpoints/element/patch-element)
- [<span class="method-delete">DELETE</span>` /<uuid> -` Delete Element](/api-endpoints/element/delete-element)
- **File Endpoints**
- [<span class="method-get">🚧 GET</span>` /<uuid>/file -` Get Element File](/api-endpoints/file/get-element-file)
- [<span class="method-post">🚧 POST</span>` /<uuid>/file -` Create Element File](/api-endpoints/file/post-element-file)
- [<span class="method-put">🚧 PUT</span>` /<uuid>/file -` Replace Element File](/api-endpoints/file/put-element-file)
- [<span class="method-patch">🚧 PATCH</span>` /<uuid>/file -` Update Element File](/api-endpoints/file/patch-element-file)
- [<span class="method-delete">🚧 DELETE</span>` /<uuid>/file -` Delete Element File](/api-endpoints/file/delete-element-file)
- **WebDAV Endpoints**
- [<span class="method-copy">🚧 COPY</span>` /<uuid> -` Copy Element](/api-endpoints/webdav/copy-element)
- [<span class="method-lock">🚧 LOCK</span>` /<uuid> -` Lock Element](/api-endpoints/webdav/lock-element)
- [<span class="method-unlock">🚧 UNLOCK</span>` /<uuid> -` Unlock Element](/api-endpoints/webdav/unlock-element)
- [<span class="method-mkcol">🚧 MKCOL</span>` /<uuid> -` Create Folder](/api-endpoints/webdav/mkcol-folder)
- [<span class="method-move">🚧 MOVE</span>` /<uuid> -` Move Element](/api-endpoints/webdav/move-element)
- [<span class="method-propfind">🚧 PROPFIND</span>` /<uuid> -` Find Element Property](/api-endpoints/webdav/propfind-element)
- [<span class="method-proppatch">🚧 PROPPATCH</span>` /<uuid> -` Change Element Property](/api-endpoints/webdav/proppatch-element)
- **Search Endpoints**
- [<span class="method-post">POST</span>` /search -` Search](/api-endpoints/search/post-search)
- **System Endpoints**
- [<span class="method-get">GET</span>` /instance-configuration -` Get Instance Configuration](/api-endpoints/system/get-instance-configuration)
- **Error Endpoints**
- [<span class="method-get">GET</span>` /error/400/bad-content`](/api-endpoints/error/get-400-bad-content)
- [<span class="method-get">GET</span>` /error/400/forbidden-property`](/api-endpoints/error/get-400-forbidden-property)
- [<span class="method-get">GET</span>` /error/400/incomplete-mutual-dependency`](/api-endpoints/error/get-400-incomplete-mutual-dependency)
- [<span class="method-get">GET</span>` /error/400/missing-property`](/api-endpoints/error/get-400-missing-property)

- Commands
- [Backup Commands](/commands/backup)
- [Database Commands](/commands/database)
Expand Down
5 changes: 0 additions & 5 deletions docs/api-endpoints/delete-element.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/api-endpoints/delete-session.md

This file was deleted.

151 changes: 151 additions & 0 deletions docs/api-endpoints/element/delete-element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# <span class="method-delete">DELETE</span>` /<uuid> -` Delete Element

<!-- panels:start -->
<!-- div:left-panel -->

Deletes a single element. If the deleted element is a node, all connected relationships are deleted.

!> **Note**: In order to avoid orphaned nodes, children need to be deleted first or get other parents added.
This behaviour might be changed, see issue [#64: HTTP DELETE /&lt;uuid&gt; - DeleteElementController](https://github.com/ember-nexus/api/issues/64).

## Request Example

```bash
curl \
-X DELETE
-H "Authorization: Bearer secret-token:PIPeJGUt7c00ENn8a5uDlc" \
https://api.localhost/2f99440e-ca4c-4e83-bf86-1cd27a4b1b70
```

<!-- tabs:start -->

### **Success 204**

The element is now deleted. No content is returned.

### **Error 401**

This error can only be thrown, if the token is invalid or if there is no default anonymous user.

```problem+json
{
"type": "Invalid authorization token",
"title": "Unauthorized",
"status": "401",
"detail": "Request requires authorization."
}
```

### **Error 404**

Error 404 is thrown if the element to be deleted does not exist, or if the use does not have permissions to delete the
element.

```problem+json
{
"type": "Invalid authorization token",
"title": "wip",
"status": "404",
"detail": "wip"
}
```

### **Error 429**

```problem+json
{
"type": "429-too-many-requests",
"title": "Too Many Requests",
"status": "429",
"detail": "The client sent too many requests in a given timeframe; rate limiting is active."
}
```

<!-- tabs:end -->

<!-- div:right-panel -->

## Internal Workflow

Once the server receives such a request, it checks several things internally:

<div id="graph-container-1" class="graph-container" style="height:1200px"></div>

<!-- panels:end -->

<script>
G6.registerEdge('polyline-edge', {
draw(cfg, group) {
const { startPoint, endPoint } = cfg;
const hgap = Math.abs(endPoint.x - startPoint.x);

const path = [
['M', startPoint.x, startPoint.y],
[
'C',
startPoint.x + hgap / 4,
startPoint.y,
endPoint.x - hgap / 2,
endPoint.y,
endPoint.x,
endPoint.y,
],
];
const shape = group.addShape('path', {
attrs: {
stroke: '#AAB7C4',
path,
},
name: 'path-shape',
});
const midPoint = {
x: (startPoint.x + endPoint.x) / 2,
y: (startPoint.y + endPoint.y) / 2,
};
const label = group.addShape('text', {
attrs: {
text: cfg.label + '###########',
x: midPoint.x,
y: midPoint.y,
textAlign: 'center',
textBaseline: 'middle',
fill: '#000',
fontSize: 14,
},
name: 'label-shape',
});
return shape;
},
});
renderWorkflow(document.getElementById('graph-container-1'), {
nodes: [
{ id: 'init', ...workflowStart, label: 'server receives DELETE-request' },
{ id: 'checkToken', ...workflowDecision, label: 'does request contain token?' },
{ id: 'noTokenAction', ...workflowStep, label: "use default anonymous\nuser for auth" },
{ id: 'checkTokenValidity', ...workflowDecision, label: 'is token valid?' },
{ id: 'checkRateLimit', ...workflowDecision, label: "does request exceed\nrate limit?" },
{ id: 'checkExistence', ...workflowDecision, label: 'does element exist?' },
{ id: 'checkAccess', ...workflowDecision, label: 'has user permission\nto delete element?' },
{ id: 'deleteElement', ...workflowStep, label: 'delete element' },
{ id: 'error401', ...workflowEndError, label: "return 401" },
{ id: 'error404', ...workflowEndError, label: "return 404" },
{ id: 'error429', ...workflowEndError, label: 'return 429' },
{ id: 'success204', ...workflowEndSuccess , label: "return 204"},
],
edges: [
{ source: 'init', target: 'checkToken', label: '' },
{ source: 'checkToken', target: 'checkTokenValidity', label: 'yes' },
{ source: 'checkToken', target: 'noTokenAction', label: 'no' },
{ source: 'checkTokenValidity', target: 'checkRateLimit', label: 'yes' },
{ source: 'checkTokenValidity', target: 'error401', label: 'no' },
{ source: 'checkRateLimit', target: 'checkExistence', label: 'no' },
{ source: 'checkRateLimit', target: 'error429', label: 'yes' },
{ source: 'checkExistence', target: 'checkAccess', label: 'yes' },
{ source: 'checkExistence', target: 'error404', label: 'no' },
{ source: 'checkAccess', target: 'deleteElement', label: 'yes' },
{ source: 'checkAccess', target: 'error404', label: 'no' },
{ source: 'deleteElement', target: 'success204' },
{ source: 'noTokenAction', target: 'checkRateLimit', label: '', type2: 'polyline-edge' }
],
}, 'TB');
</script>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET /&lt;uuid&gt;/children - Get Children
# <span class="method-get">GET</span>` /<uuid>/children -` Get Children

Returns all children of the specified node.
Returned data is paginated, can be filtered/sorted (?) and each page contains all relations between the parent and the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET /&lt;uuid&gt; - Get Element
# <span class="method-get">GET</span>` /<uuid> -` Get Element

<!-- panels:start -->
<!-- div:left-panel -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET / - Get Index
# <span class="method-get">GET</span>` / -` Get Index

<!-- panels:start -->
<!-- div:left-panel -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET /&lt;uuid&gt;/parents - Get Parents
# <span class="method-get">GET</span>` /<uuid>/parents -` Get Parents

Returns all parents of the specified node.
Returned data is paginated, can be filtered/sorted (?) and each page contains all relations between the node and the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET /&lt;uuid&gt;/related - Get Related
# <span class="method-get">GET</span>` /<uuid>/related -` Get Related

Returns all nodes related to the current node.
Returned data is paginated, can be filtered/sorted (?) and each page contains all relations between the node and the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PATCH /&lt;uuid&gt; - Update Element
# <span class="method-patch">PATCH</span>` /<uuid> -` Update Element

Updates an individual data element.

Expand Down
3 changes: 3 additions & 0 deletions docs/api-endpoints/element/post-element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# <span class="method-post">POST</span>` /<uuid> -` Create Element

Creates a new data element. It is owned by the referenced node.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# POST / - Create Root Element
# <span class="method-post">POST</span>` / -` Create Root Element

Creates a new data element. If the data element is a node, it is directly owned by the current user.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PUT /&lt;uuid&gt; - Replace Element
# <span class="method-put">PUT</span>` /<uuid> -` Replace Element

Replaces the data of an individual data element.

Expand Down
1 change: 1 addition & 0 deletions docs/api-endpoints/error/get-400-bad-content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <span class="method-get">GET</span>` /error/400/bad-content`
1 change: 1 addition & 0 deletions docs/api-endpoints/error/get-400-forbidden-property.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <span class="method-get">GET</span>` /error/400/forbidden-property`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <span class="method-get">GET</span>` /error/400/incomplete-mutual-dependency`
1 change: 1 addition & 0 deletions docs/api-endpoints/error/get-400-missing-property.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <span class="method-get">GET</span>` /error/400/missing-property`
4 changes: 4 additions & 0 deletions docs/api-endpoints/file/delete-element-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <span class="method-delete">🚧 DELETE</span>` /<uuid>/file -` Delete Element File

!> **Currently not implemented.**
This feature is reserved for the version [0.2.0](https://github.com/ember-nexus/api/milestone/1).
4 changes: 4 additions & 0 deletions docs/api-endpoints/file/get-element-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <span class="method-get">🚧 GET</span>` /<uuid>/file -` Get Element File

!> **Currently not implemented.**
This feature is reserved for the version [0.2.0](https://github.com/ember-nexus/api/milestone/1).
4 changes: 4 additions & 0 deletions docs/api-endpoints/file/patch-element-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <span class="method-patch">🚧 PATCH</span>` /<uuid>/file -` Update Element File

!> **Currently not implemented.**
This feature is reserved for the version [0.2.0](https://github.com/ember-nexus/api/milestone/1).
4 changes: 4 additions & 0 deletions docs/api-endpoints/file/post-element-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <span class="method-post">🚧 POST</span>` /<uuid>/file -` Create Element File

!> **Currently not implemented.**
This feature is reserved for the version [0.2.0](https://github.com/ember-nexus/api/milestone/1).
4 changes: 4 additions & 0 deletions docs/api-endpoints/file/put-element-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <span class="method-put">🚧 PUT</span>` /<uuid>/file -` Replace Element File

!> **Currently not implemented.**
This feature is reserved for the version [0.2.0](https://github.com/ember-nexus/api/milestone/1).
3 changes: 0 additions & 3 deletions docs/api-endpoints/get-sessions.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-endpoints/get-specific-session.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-endpoints/patch-sessions.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api-endpoints/post-element.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/api-endpoints/post-sessions.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# POST /search - Search
# <span class="method-post">POST</span>` /search -` Search

<!-- panels:start -->
<!-- div:left-panel -->

!> **Note**: This endpoint might be changed during development to the
[0.3.0](https://github.com/ember-nexus/api/milestone/3) version.

The post search endpoint at `POST /search` is used to execute [Elasticsearch](https://www.elastic.co/) queries and
return found elements.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GET /instance-configuration - Get Instance Configuration
# <span class="method-get">GET</span>` /instance-configuration -` Get Instance Configuration

<!-- panels:start -->
<!-- div:left-panel -->
Expand Down
3 changes: 3 additions & 0 deletions docs/api-endpoints/user/delete-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# <span class="method-delete">DELETE</span>` /token -` Delete Token

Deletes the currently used token.
7 changes: 7 additions & 0 deletions docs/api-endpoints/user/get-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# <span class="method-get">GET</span>` /token -` Get Token

Returns the currently used token.

To display all tokens, you can return all root elements and filter for the `Token` type.

Currently under development.
Loading

0 comments on commit d338e6f

Please sign in to comment.