@toa.io/extensions.exposition 0.9.0-canary.2 → 0.20.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/context.toa.yaml +15 -0
- package/components/identity.bans/manifest.toa.yaml +18 -0
- package/components/identity.basic/events/principal.js +9 -0
- package/components/identity.basic/manifest.toa.yaml +50 -0
- package/components/identity.basic/source/authenticate.ts +29 -0
- package/components/identity.basic/source/create.ts +19 -0
- package/components/identity.basic/source/transit.ts +64 -0
- package/components/identity.basic/source/types.ts +42 -0
- package/components/identity.basic/tsconfig.json +9 -0
- package/components/identity.roles/manifest.toa.yaml +31 -0
- package/components/identity.roles/source/list.ts +7 -0
- package/components/identity.roles/source/principal.ts +20 -0
- package/components/identity.roles/tsconfig.json +9 -0
- package/components/identity.tokens/manifest.toa.yaml +39 -0
- package/components/identity.tokens/receivers/identity.bans.updated.js +3 -0
- package/components/identity.tokens/source/authenticate.test.ts +56 -0
- package/components/identity.tokens/source/authenticate.ts +38 -0
- package/components/identity.tokens/source/decrypt.test.ts +59 -0
- package/components/identity.tokens/source/decrypt.ts +25 -0
- package/components/identity.tokens/source/encrypt.test.ts +35 -0
- package/components/identity.tokens/source/encrypt.ts +25 -0
- package/components/identity.tokens/source/revoke.ts +5 -0
- package/components/identity.tokens/source/types.ts +48 -0
- package/components/identity.tokens/tsconfig.json +9 -0
- package/cucumber.js +9 -0
- package/documentation/.assets/ia3-dark.jpg +0 -0
- package/documentation/.assets/ia3-light.jpg +0 -0
- package/documentation/.assets/overview-dark.jpg +0 -0
- package/documentation/.assets/overview-light.jpg +0 -0
- package/documentation/.assets/role-scopes-dark.jpg +0 -0
- package/documentation/.assets/role-scopes-light.jpg +0 -0
- package/documentation/.assets/rtd-dark.jpg +0 -0
- package/documentation/.assets/rtd-light.jpg +0 -0
- package/documentation/access.md +256 -0
- package/documentation/components.md +276 -0
- package/documentation/identity.md +156 -0
- package/documentation/protocol.md +15 -0
- package/documentation/query.md +226 -0
- package/documentation/tree.md +169 -0
- package/features/access.feature +442 -0
- package/features/annotation.feature +28 -0
- package/features/body.feature +21 -0
- package/features/directives.feature +56 -0
- package/features/dynamic.feature +89 -0
- package/features/errors.feature +208 -0
- package/features/identity.basic.feature +235 -0
- package/features/identity.feature +61 -0
- package/features/identity.roles.feature +51 -0
- package/features/identity.tokens.feature +116 -0
- package/features/queries.feature +214 -0
- package/features/routes.feature +49 -0
- package/features/steps/Common.ts +10 -0
- package/features/steps/Components.ts +43 -0
- package/features/steps/Database.ts +58 -0
- package/features/steps/Gateway.ts +105 -0
- package/features/steps/HTTP.ts +71 -0
- package/features/steps/Parameters.ts +12 -0
- package/features/steps/Workspace.ts +40 -0
- package/features/steps/components/greeter/manifest.toa.yaml +9 -0
- package/features/steps/components/greeter/operations/greet.js +7 -0
- package/features/steps/components/pots/manifest.toa.yaml +20 -0
- package/features/steps/components/users/manifest.toa.yaml +11 -0
- package/features/steps/tsconfig.json +9 -0
- package/package.json +31 -17
- package/readme.md +181 -0
- package/schemas/annotation.cos.yaml +4 -0
- package/schemas/directive.cos.yaml +3 -0
- package/schemas/method.cos.yaml +9 -0
- package/schemas/node.cos.yaml +5 -0
- package/schemas/query.cos.yaml +16 -0
- package/schemas/querystring.cos.yaml +5 -0
- package/schemas/range.cos.yaml +2 -0
- package/schemas/route.cos.yaml +2 -0
- package/source/Annotation.ts +6 -0
- package/source/Branch.ts +8 -0
- package/source/Composition.ts +58 -0
- package/source/Context.ts +6 -0
- package/source/Directive.test.ts +91 -0
- package/source/Directive.ts +120 -0
- package/source/Endpoint.ts +57 -0
- package/source/Factory.ts +53 -0
- package/source/Gateway.ts +93 -0
- package/source/HTTP/Server.fixtures.ts +45 -0
- package/source/HTTP/Server.test.ts +221 -0
- package/source/HTTP/Server.ts +135 -0
- package/source/HTTP/exceptions.ts +77 -0
- package/source/HTTP/formats/index.ts +19 -0
- package/source/HTTP/formats/json.ts +13 -0
- package/source/HTTP/formats/msgpack.ts +10 -0
- package/source/HTTP/formats/text.ts +9 -0
- package/source/HTTP/formats/yaml.ts +14 -0
- package/source/HTTP/index.ts +3 -0
- package/source/HTTP/messages.test.ts +116 -0
- package/source/HTTP/messages.ts +77 -0
- package/source/Mapping.ts +48 -0
- package/source/Query.test.ts +37 -0
- package/source/Query.ts +105 -0
- package/source/RTD/Context.ts +16 -0
- package/source/RTD/Directives.ts +9 -0
- package/source/RTD/Endpoint.ts +11 -0
- package/source/RTD/Match.ts +16 -0
- package/source/RTD/Method.ts +24 -0
- package/source/RTD/Node.ts +85 -0
- package/source/RTD/Route.ts +58 -0
- package/source/RTD/Tree.ts +57 -0
- package/source/RTD/factory.ts +47 -0
- package/source/RTD/index.ts +8 -0
- package/source/RTD/segment.test.ts +32 -0
- package/source/RTD/segment.ts +25 -0
- package/source/RTD/syntax/index.ts +2 -0
- package/source/RTD/syntax/parse.test.ts +188 -0
- package/source/RTD/syntax/parse.ts +153 -0
- package/source/RTD/syntax/types.ts +48 -0
- package/source/Remotes.test.ts +41 -0
- package/source/Remotes.ts +20 -0
- package/source/Tenant.ts +38 -0
- package/source/deployment.ts +42 -0
- package/source/directives/auth/Anonymous.ts +14 -0
- package/source/directives/auth/Echo.ts +12 -0
- package/source/directives/auth/Family.ts +145 -0
- package/source/directives/auth/Id.ts +19 -0
- package/source/directives/auth/Incept.ts +42 -0
- package/source/directives/auth/Role.test.ts +62 -0
- package/source/directives/auth/Role.ts +56 -0
- package/source/directives/auth/Rule.ts +28 -0
- package/source/directives/auth/Scheme.ts +26 -0
- package/source/directives/auth/index.ts +3 -0
- package/source/directives/auth/schemes.ts +8 -0
- package/source/directives/auth/split.ts +15 -0
- package/source/directives/auth/types.ts +37 -0
- package/source/directives/dev/Family.ts +34 -0
- package/source/directives/dev/Stub.ts +14 -0
- package/source/directives/dev/index.ts +3 -0
- package/source/directives/dev/types.ts +5 -0
- package/source/directives/index.ts +5 -0
- package/source/discovery.ts +1 -0
- package/source/exceptions.ts +17 -0
- package/source/index.test.ts +9 -0
- package/source/index.ts +6 -0
- package/source/manifest.test.ts +57 -0
- package/source/manifest.ts +35 -0
- package/source/root.ts +38 -0
- package/source/schemas.ts +9 -0
- package/transpiled/Annotation.d.ts +6 -0
- package/transpiled/Annotation.js +3 -0
- package/transpiled/Annotation.js.map +1 -0
- package/transpiled/Branch.d.ts +7 -0
- package/transpiled/Branch.js +3 -0
- package/transpiled/Branch.js.map +1 -0
- package/transpiled/Composition.d.ts +14 -0
- package/transpiled/Composition.js +43 -0
- package/transpiled/Composition.js.map +1 -0
- package/transpiled/Context.d.ts +5 -0
- package/transpiled/Context.js +3 -0
- package/transpiled/Context.js.map +1 -0
- package/transpiled/Directive.d.ts +32 -0
- package/transpiled/Directive.js +76 -0
- package/transpiled/Directive.js.map +1 -0
- package/transpiled/Endpoint.d.ts +20 -0
- package/transpiled/Endpoint.js +44 -0
- package/transpiled/Endpoint.js.map +1 -0
- package/transpiled/Factory.d.ts +11 -0
- package/transpiled/Factory.js +67 -0
- package/transpiled/Factory.js.map +1 -0
- package/transpiled/Gateway.d.ts +19 -0
- package/transpiled/Gateway.js +90 -0
- package/transpiled/Gateway.js.map +1 -0
- package/transpiled/HTTP/Server.d.ts +22 -0
- package/transpiled/HTTP/Server.fixtures.d.ts +12 -0
- package/transpiled/HTTP/Server.fixtures.js +36 -0
- package/transpiled/HTTP/Server.fixtures.js.map +1 -0
- package/transpiled/HTTP/Server.js +111 -0
- package/transpiled/HTTP/Server.js.map +1 -0
- package/transpiled/HTTP/exceptions.d.ts +39 -0
- package/transpiled/HTTP/exceptions.js +78 -0
- package/transpiled/HTTP/exceptions.js.map +1 -0
- package/transpiled/HTTP/formats/index.d.ts +8 -0
- package/transpiled/HTTP/formats/index.js +38 -0
- package/transpiled/HTTP/formats/index.js.map +1 -0
- package/transpiled/HTTP/formats/json.d.ts +4 -0
- package/transpiled/HTTP/formats/json.js +15 -0
- package/transpiled/HTTP/formats/json.js.map +1 -0
- package/transpiled/HTTP/formats/msgpack.d.ts +4 -0
- package/transpiled/HTTP/formats/msgpack.js +36 -0
- package/transpiled/HTTP/formats/msgpack.js.map +1 -0
- package/transpiled/HTTP/formats/text.d.ts +4 -0
- package/transpiled/HTTP/formats/text.js +13 -0
- package/transpiled/HTTP/formats/text.js.map +1 -0
- package/transpiled/HTTP/formats/yaml.d.ts +4 -0
- package/transpiled/HTTP/formats/yaml.js +39 -0
- package/transpiled/HTTP/formats/yaml.js.map +1 -0
- package/transpiled/HTTP/index.d.ts +3 -0
- package/transpiled/HTTP/index.js +20 -0
- package/transpiled/HTTP/index.js.map +1 -0
- package/transpiled/HTTP/messages.d.ts +27 -0
- package/transpiled/HTTP/messages.js +49 -0
- package/transpiled/HTTP/messages.js.map +1 -0
- package/transpiled/Mapping.d.ts +8 -0
- package/transpiled/Mapping.js +35 -0
- package/transpiled/Mapping.js.map +1 -0
- package/transpiled/Query.d.ts +13 -0
- package/transpiled/Query.js +107 -0
- package/transpiled/Query.js.map +1 -0
- package/transpiled/RTD/Context.d.ts +11 -0
- package/transpiled/RTD/Context.js +3 -0
- package/transpiled/RTD/Context.js.map +1 -0
- package/transpiled/RTD/Directives.d.ts +7 -0
- package/transpiled/RTD/Directives.js +3 -0
- package/transpiled/RTD/Directives.js.map +1 -0
- package/transpiled/RTD/Endpoint.d.ts +9 -0
- package/transpiled/RTD/Endpoint.js +3 -0
- package/transpiled/RTD/Endpoint.js.map +1 -0
- package/transpiled/RTD/Match.d.ts +11 -0
- package/transpiled/RTD/Match.js +3 -0
- package/transpiled/RTD/Match.js.map +1 -0
- package/transpiled/RTD/Method.d.ts +9 -0
- package/transpiled/RTD/Method.js +16 -0
- package/transpiled/RTD/Method.js.map +1 -0
- package/transpiled/RTD/Node.d.ts +21 -0
- package/transpiled/RTD/Node.js +61 -0
- package/transpiled/RTD/Node.js.map +1 -0
- package/transpiled/RTD/Route.d.ts +14 -0
- package/transpiled/RTD/Route.js +48 -0
- package/transpiled/RTD/Route.js.map +1 -0
- package/transpiled/RTD/Tree.d.ts +14 -0
- package/transpiled/RTD/Tree.js +45 -0
- package/transpiled/RTD/Tree.js.map +1 -0
- package/transpiled/RTD/factory.d.ts +6 -0
- package/transpiled/RTD/factory.js +36 -0
- package/transpiled/RTD/factory.js.map +1 -0
- package/transpiled/RTD/index.d.ts +8 -0
- package/transpiled/RTD/index.js +38 -0
- package/transpiled/RTD/index.js.map +1 -0
- package/transpiled/RTD/segment.d.ts +8 -0
- package/transpiled/RTD/segment.js +23 -0
- package/transpiled/RTD/segment.js.map +1 -0
- package/transpiled/RTD/syntax/index.d.ts +2 -0
- package/transpiled/RTD/syntax/index.js +19 -0
- package/transpiled/RTD/syntax/index.js.map +1 -0
- package/transpiled/RTD/syntax/parse.d.ts +4 -0
- package/transpiled/RTD/syntax/parse.js +128 -0
- package/transpiled/RTD/syntax/parse.js.map +1 -0
- package/transpiled/RTD/syntax/types.d.ts +41 -0
- package/transpiled/RTD/syntax/types.js +5 -0
- package/transpiled/RTD/syntax/types.js.map +1 -0
- package/transpiled/Remotes.d.ts +7 -0
- package/transpiled/Remotes.js +19 -0
- package/transpiled/Remotes.js.map +1 -0
- package/transpiled/Tenant.d.ts +12 -0
- package/transpiled/Tenant.js +30 -0
- package/transpiled/Tenant.js.map +1 -0
- package/transpiled/deployment.d.ts +3 -0
- package/transpiled/deployment.js +61 -0
- package/transpiled/deployment.js.map +1 -0
- package/transpiled/directives/auth/Anonymous.d.ts +6 -0
- package/transpiled/directives/auth/Anonymous.js +17 -0
- package/transpiled/directives/auth/Anonymous.js.map +1 -0
- package/transpiled/directives/auth/Echo.d.ts +6 -0
- package/transpiled/directives/auth/Echo.js +13 -0
- package/transpiled/directives/auth/Echo.js.map +1 -0
- package/transpiled/directives/auth/Family.d.ts +20 -0
- package/transpiled/directives/auth/Family.js +125 -0
- package/transpiled/directives/auth/Family.js.map +1 -0
- package/transpiled/directives/auth/Id.d.ts +7 -0
- package/transpiled/directives/auth/Id.js +17 -0
- package/transpiled/directives/auth/Id.js.map +1 -0
- package/transpiled/directives/auth/Incept.d.ts +10 -0
- package/transpiled/directives/auth/Incept.js +59 -0
- package/transpiled/directives/auth/Incept.js.map +1 -0
- package/transpiled/directives/auth/Role.d.ts +11 -0
- package/transpiled/directives/auth/Role.js +44 -0
- package/transpiled/directives/auth/Role.js.map +1 -0
- package/transpiled/directives/auth/Rule.d.ts +9 -0
- package/transpiled/directives/auth/Rule.js +22 -0
- package/transpiled/directives/auth/Rule.js.map +1 -0
- package/transpiled/directives/auth/Scheme.d.ts +7 -0
- package/transpiled/directives/auth/Scheme.js +47 -0
- package/transpiled/directives/auth/Scheme.js.map +1 -0
- package/transpiled/directives/auth/index.d.ts +2 -0
- package/transpiled/directives/auth/index.js +7 -0
- package/transpiled/directives/auth/index.js.map +1 -0
- package/transpiled/directives/auth/schemes.d.ts +3 -0
- package/transpiled/directives/auth/schemes.js +9 -0
- package/transpiled/directives/auth/schemes.js.map +1 -0
- package/transpiled/directives/auth/split.d.ts +2 -0
- package/transpiled/directives/auth/split.js +38 -0
- package/transpiled/directives/auth/split.js.map +1 -0
- package/transpiled/directives/auth/types.d.ts +31 -0
- package/transpiled/directives/auth/types.js +3 -0
- package/transpiled/directives/auth/types.js.map +1 -0
- package/transpiled/directives/dev/Family.d.ts +10 -0
- package/transpiled/directives/dev/Family.js +25 -0
- package/transpiled/directives/dev/Family.js.map +1 -0
- package/transpiled/directives/dev/Stub.d.ts +7 -0
- package/transpiled/directives/dev/Stub.js +14 -0
- package/transpiled/directives/dev/Stub.js.map +1 -0
- package/transpiled/directives/dev/index.d.ts +2 -0
- package/transpiled/directives/dev/index.js +7 -0
- package/transpiled/directives/dev/index.js.map +1 -0
- package/transpiled/directives/dev/types.d.ts +4 -0
- package/transpiled/directives/dev/types.js +3 -0
- package/transpiled/directives/dev/types.js.map +1 -0
- package/transpiled/directives/index.d.ts +2 -0
- package/transpiled/directives/index.js +10 -0
- package/transpiled/directives/index.js.map +1 -0
- package/transpiled/discovery.d.ts +1 -0
- package/transpiled/discovery.js +3 -0
- package/transpiled/discovery.js.map +1 -0
- package/transpiled/exceptions.d.ts +2 -0
- package/transpiled/exceptions.js +39 -0
- package/transpiled/exceptions.js.map +1 -0
- package/transpiled/index.d.ts +5 -0
- package/transpiled/index.js +12 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/manifest.d.ts +3 -0
- package/transpiled/manifest.js +30 -0
- package/transpiled/manifest.js.map +1 -0
- package/transpiled/root.d.ts +2 -0
- package/transpiled/root.js +39 -0
- package/transpiled/root.js.map +1 -0
- package/transpiled/schemas.d.ts +3 -0
- package/transpiled/schemas.js +14 -0
- package/transpiled/schemas.js.map +1 -0
- package/transpiled/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.json +12 -0
- package/src/.manifest/index.js +0 -7
- package/src/.manifest/normalize.js +0 -58
- package/src/.manifest/schema.yaml +0 -71
- package/src/.manifest/validate.js +0 -17
- package/src/constants.js +0 -3
- package/src/deployment.js +0 -23
- package/src/exposition.js +0 -68
- package/src/factory.js +0 -76
- package/src/index.js +0 -9
- package/src/manifest.js +0 -12
- package/src/query/criteria.js +0 -55
- package/src/query/enum.js +0 -35
- package/src/query/index.js +0 -17
- package/src/query/query.js +0 -60
- package/src/query/range.js +0 -28
- package/src/query/sort.js +0 -19
- package/src/remote.js +0 -88
- package/src/server.js +0 -83
- package/src/tenant.js +0 -29
- package/src/translate/etag.js +0 -14
- package/src/translate/index.js +0 -7
- package/src/translate/request.js +0 -68
- package/src/translate/response.js +0 -62
- package/src/tree.js +0 -109
- package/test/manifest.normalize.fixtures.js +0 -37
- package/test/manifest.normalize.test.js +0 -37
- package/test/manifest.validate.test.js +0 -40
- package/test/query.range.test.js +0 -18
- package/test/tree.fixtures.js +0 -21
- package/test/tree.test.js +0 -44
- package/types/annotations.d.ts +0 -10
- package/types/declarations.d.ts +0 -31
- package/types/exposition.d.ts +0 -13
- package/types/http.d.ts +0 -13
- package/types/query.d.ts +0 -16
- package/types/remote.d.ts +0 -19
- package/types/server.d.ts +0 -13
- package/types/tree.d.ts +0 -33
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Protocol Support
|
|
2
|
+
|
|
3
|
+
## Media types
|
|
4
|
+
|
|
5
|
+
The following media types are supported for both requests and responses:
|
|
6
|
+
|
|
7
|
+
- `application/json`
|
|
8
|
+
- `application/yaml` using [js-yaml](https://github.com/nodeca/js-yaml)
|
|
9
|
+
- `application/msgpack` using [msgpackr](https://github.com/kriszyp/msgpackr)
|
|
10
|
+
- `text/plain`
|
|
11
|
+
|
|
12
|
+
The response format is determined by content negotiation
|
|
13
|
+
using [negotiator](https://github.com/jshttp/negotiator).
|
|
14
|
+
|
|
15
|
+
> Errors are always sent as `text/plain`. See [debug mode](../readme.md#context-annotation).
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Query mapping
|
|
2
|
+
|
|
3
|
+
## TL;DR
|
|
4
|
+
|
|
5
|
+
```yaml
|
|
6
|
+
id?: string
|
|
7
|
+
criteria?: string
|
|
8
|
+
sort?: string
|
|
9
|
+
omit?: [integer]
|
|
10
|
+
limit?: [integer]
|
|
11
|
+
selectors?: string[]
|
|
12
|
+
projection?: [string]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
# manifest.toa.yaml
|
|
17
|
+
|
|
18
|
+
name: pots
|
|
19
|
+
namespace: tea
|
|
20
|
+
|
|
21
|
+
exposition:
|
|
22
|
+
/hot:
|
|
23
|
+
GET:
|
|
24
|
+
endpoint: enumerate
|
|
25
|
+
query:
|
|
26
|
+
criteria: state==hot
|
|
27
|
+
/top10:
|
|
28
|
+
GET:
|
|
29
|
+
endpoint: enumerate
|
|
30
|
+
query:
|
|
31
|
+
criteria: state==hot
|
|
32
|
+
sort: rank:desc
|
|
33
|
+
limit: 10
|
|
34
|
+
/latest:
|
|
35
|
+
GET:
|
|
36
|
+
endpoint: observe
|
|
37
|
+
query:
|
|
38
|
+
sort: timestamp:desc
|
|
39
|
+
limit: 1
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Undefined `query` denies any query arguments in requests.
|
|
43
|
+
|
|
44
|
+
`POST` method mapping cannot have `query` declaration.
|
|
45
|
+
|
|
46
|
+
## Criteria
|
|
47
|
+
|
|
48
|
+
Search critaria in [RSQL](https://github.com/jirutka/rsql-parser) format.
|
|
49
|
+
|
|
50
|
+
The `criteria` property is considered as *open* when it ends with a `;`, allowing the combination of
|
|
51
|
+
request query criteria using `and` logic.
|
|
52
|
+
Otherwise, criteria property is *closed*, that is, doesn't allow `criteria` in a request query.
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
# manifest.toa.yaml
|
|
56
|
+
|
|
57
|
+
name: dummy
|
|
58
|
+
|
|
59
|
+
exposition:
|
|
60
|
+
/:
|
|
61
|
+
GET:
|
|
62
|
+
endpoint: observe
|
|
63
|
+
query:
|
|
64
|
+
criteria: state==hot; # open criteria
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```http
|
|
68
|
+
GET /dummies/?criteria=rank==5
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The request example above will result in an operation call with the following Request:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
query:
|
|
75
|
+
criteria: state==hot;rank=5
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Path variables
|
|
79
|
+
|
|
80
|
+
Path variables are prepended to the `criteria` request query parameter using logial AND,
|
|
81
|
+
except for the [`POST` method](#post-method).
|
|
82
|
+
|
|
83
|
+
Given the following declaration:
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
# manifest.toa.yaml
|
|
87
|
+
|
|
88
|
+
name: dummies
|
|
89
|
+
|
|
90
|
+
exposition:
|
|
91
|
+
/:type:
|
|
92
|
+
GET:
|
|
93
|
+
endpoint: observe
|
|
94
|
+
query:
|
|
95
|
+
criteria: state==hot; # open criteria
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
and the following request:
|
|
99
|
+
|
|
100
|
+
```http request
|
|
101
|
+
GET /dummies/cool/?criteria=rank==5
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Operation call will have the following query criteria:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
criteria: state==hot;type==cool;rank=5
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### POST method
|
|
111
|
+
|
|
112
|
+
`POST` method semantically used to create a new entity instance, that is, calling a Transition
|
|
113
|
+
without Query.
|
|
114
|
+
Thus, path variables are added to the request input.
|
|
115
|
+
|
|
116
|
+
Given the following declaration:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
# manifest.toa.yaml
|
|
120
|
+
|
|
121
|
+
name: dummies
|
|
122
|
+
|
|
123
|
+
exposition:
|
|
124
|
+
/:type:
|
|
125
|
+
POST: transit
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
and the following request:
|
|
129
|
+
|
|
130
|
+
```http request
|
|
131
|
+
POST /dummies/cool/
|
|
132
|
+
content-type: application/yaml
|
|
133
|
+
|
|
134
|
+
input:
|
|
135
|
+
rank: 5
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Operation call will have the following input:
|
|
139
|
+
|
|
140
|
+
```yaml
|
|
141
|
+
type: cool
|
|
142
|
+
rank: 5
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> In case of conflict, path variables override input properties.
|
|
146
|
+
|
|
147
|
+
## Omit, limit
|
|
148
|
+
|
|
149
|
+
`omit` and `limit` properties can declare their default values and allowed boundaries:
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
limit:
|
|
153
|
+
value: 10
|
|
154
|
+
range: [1, 100]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
If no default value is provided, then the lower boundary of the range is used.
|
|
158
|
+
|
|
159
|
+
Default values for `omit` and `limit` are:
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
omit:
|
|
163
|
+
value: 0
|
|
164
|
+
range: [0, 1000]
|
|
165
|
+
limit:
|
|
166
|
+
value: 10
|
|
167
|
+
range: [1, 1000]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Constant values can be declared using the shortcut:
|
|
171
|
+
|
|
172
|
+
```yaml
|
|
173
|
+
limit: 10
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Sort
|
|
177
|
+
|
|
178
|
+
The `sort` query property defines the result order of Observations within an `objects` scope
|
|
179
|
+
(enumeration).
|
|
180
|
+
It comprises an ordered set of sorting statements delimited by semicolons.
|
|
181
|
+
Each statement consists of an entity property name with an optional sorting direction suffix:
|
|
182
|
+
`:asc`for ascending or `:desc` for descending.
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
sort: rank # ascending by default
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
sort: rank:asc
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```yaml
|
|
193
|
+
sort: rank:desc;timestamp:asc
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If `sort` value ends with a semicolon `;` then the sorting is considered *open*
|
|
197
|
+
and can be extended using request query `sort` argument.
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
sort: rank:desc; # open sort
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Having the above `sort` declaration, the following request will result in an operation call
|
|
204
|
+
with `rank:desc;timestamp:asc` sort:
|
|
205
|
+
|
|
206
|
+
```http
|
|
207
|
+
GET /dummies/?sort=timestamp:asc
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Selectors
|
|
211
|
+
|
|
212
|
+
The `selectors` query property contains a list of Entity properties allowed for a client to use in
|
|
213
|
+
the `criteria` and `sort` query parameters.
|
|
214
|
+
If no value is provided, then no selectors are allowed.
|
|
215
|
+
|
|
216
|
+
```yaml
|
|
217
|
+
selectors: [rank, timestamp]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Projection
|
|
221
|
+
|
|
222
|
+
A list of Entity properties to be included in the Observation result.
|
|
223
|
+
|
|
224
|
+
```yaml
|
|
225
|
+
projection: [id, title, timestamp]
|
|
226
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Resource Tree Declaration
|
|
2
|
+
|
|
3
|
+
The foundation of a Resource Tree Declaration (RTD) is an RTD node.
|
|
4
|
+
An RTD node is an object that consists of _Routes_, _Methods_ and _Directives_.
|
|
5
|
+
|
|
6
|
+
## Routes
|
|
7
|
+
|
|
8
|
+
A Route is a key starting with `/` and it has a value as a nested RTD node.
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
/:
|
|
12
|
+
/users:
|
|
13
|
+
/:user-id: ...
|
|
14
|
+
/posts:
|
|
15
|
+
/:post-id: ...
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Route declarations can also be flat, meaning that the RTD can have adjacent branches.
|
|
19
|
+
The following will represent the same resources as the above:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
/users/:user-id: ...
|
|
23
|
+
/posts/:post-id: ...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> Refer to the [Directives](#directives) section for an explanation of the differences between
|
|
27
|
+
> nested and adjacent RTD branches.
|
|
28
|
+
|
|
29
|
+
An RTD node that does not contain any Routes is called an _RTD leaf_.
|
|
30
|
+
|
|
31
|
+
> Route declarations must not have a trailing slash.
|
|
32
|
+
|
|
33
|
+
### Route variables
|
|
34
|
+
|
|
35
|
+
Route segments prefixed with a colon (`:`) are Route variables.
|
|
36
|
+
|
|
37
|
+
> A segment may include a reference to a single variable.
|
|
38
|
+
> For instance, in the route `/messages/:sender-:recipient`,
|
|
39
|
+
> a single variable is declared with the name `sender-:recipient`.
|
|
40
|
+
|
|
41
|
+
Refer to [Query mapping](query.md) for the details.
|
|
42
|
+
|
|
43
|
+
### Route conflicts
|
|
44
|
+
|
|
45
|
+
Routes with specific, non-variable segments are given precedence in routing decisions.
|
|
46
|
+
|
|
47
|
+
Consider the following route declarations:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
/users/:id: ...
|
|
51
|
+
/users/hot: ...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Request made to `/users/hot/`, will be routed to the second `/users/hot` Route,
|
|
55
|
+
as it provides a more specific match compared to the generic `/users/:id` route.
|
|
56
|
+
|
|
57
|
+
The priority of Routes with the same specificity is determined by the order of declaration.
|
|
58
|
+
|
|
59
|
+
## Methods
|
|
60
|
+
|
|
61
|
+
Methods are mappings of the HTTP methods to the corresponding operations.
|
|
62
|
+
|
|
63
|
+
A Method is a key named after the corresponding HTTP method, with a value following the schema
|
|
64
|
+
below:
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
endpoint: string
|
|
68
|
+
query?: Query
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> Refer to [Query mapping](query.md) for the details.
|
|
72
|
+
|
|
73
|
+
Methods can be present in any RTD node.
|
|
74
|
+
However, it is required that an RTD leaf must have at least one Method.
|
|
75
|
+
|
|
76
|
+
If a Method only has an `operation` key, it can be declared directly as the value of the `operation`
|
|
77
|
+
key.
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
/teapots:
|
|
81
|
+
GET:
|
|
82
|
+
endpoint: select
|
|
83
|
+
/hot:
|
|
84
|
+
GET:
|
|
85
|
+
endpoint: select
|
|
86
|
+
query:
|
|
87
|
+
criteria: state==hot
|
|
88
|
+
/posts:
|
|
89
|
+
GET: select
|
|
90
|
+
POST: transit
|
|
91
|
+
/:post-id:
|
|
92
|
+
GET: observe
|
|
93
|
+
PUT: transit
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
HTTP methods can only be mapped to operations of the corresponding types.
|
|
97
|
+
|
|
98
|
+
| HTTP method | Operation type |
|
|
99
|
+
|-------------|-----------------------------------------------|
|
|
100
|
+
| `POST` | **Transition** (without Query)<br/>**Effect** |
|
|
101
|
+
| `PUT` | **Transition** (with Query)<br/>**Effect** |
|
|
102
|
+
| `GET` | **Observation**<br/>**Computation** |
|
|
103
|
+
| `PATCH` | **Assignment**<br/>**Effect** |
|
|
104
|
+
|
|
105
|
+
As method mapping is unambiguous for Observation, Assignent, and Computation, a consice syntax is
|
|
106
|
+
available:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
/items: compute
|
|
110
|
+
/items/:id: [observe, assign]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Intermediate Nodes
|
|
114
|
+
|
|
115
|
+
An RTD Node that has a Route with a key `/` is an _intermediate_ Node.
|
|
116
|
+
Intermediate Nodes must not have Methods as they are unreachable.
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
/posts: # Node is intermediate
|
|
120
|
+
GET: select # INVALID: Method is unreachable
|
|
121
|
+
/:
|
|
122
|
+
PUT: transit
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Directives
|
|
126
|
+
|
|
127
|
+
RTD Directives are declared using RTD node or Method keys following the `{provider}:{directive}` pattern and can be used
|
|
128
|
+
to add or modify the behavior of request processing. Directive declarations are applied to the RTD node where they are
|
|
129
|
+
declared and to all nested nodes.
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
/posts/:user-id:
|
|
133
|
+
authorization:id: user-id
|
|
134
|
+
/:post-id:
|
|
135
|
+
authorization:role: editor
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
In the above example, the Route `/posts/:user-id/:post-id/` has both `authorization:id`
|
|
139
|
+
and `authorization:role` directives applied.
|
|
140
|
+
|
|
141
|
+
When it is necessary to avoid directive nesting, a Route can be declared adjacent.
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
/posts:
|
|
145
|
+
/:user-id:
|
|
146
|
+
id: user-id
|
|
147
|
+
/:user-id/:post-id:
|
|
148
|
+
role: editor
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
In this example, the Route `/posts/:user-id/:post-id/` has only the `authorization:role` directive
|
|
152
|
+
applied.
|
|
153
|
+
|
|
154
|
+
> Directives can be declared without the `{provider}:` prefix unless there are multiple directives
|
|
155
|
+
> with the same name
|
|
156
|
+
> across different providers.
|
|
157
|
+
|
|
158
|
+
Another way to avoid nesting is to declare an _isolated_ Node as follows:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
/posts:
|
|
162
|
+
/:user-id:
|
|
163
|
+
id: user-id
|
|
164
|
+
/:post-id:
|
|
165
|
+
isolated: true
|
|
166
|
+
role: editor
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
See [Access Authorization](./access.md) as an example of directive provider.
|