@toa.io/extensions.exposition 1.0.0-alpha.5 → 1.0.0-alpha.7
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/identity.basic/manifest.toa.yaml +2 -0
- package/components/identity.federation/manifest.toa.yaml +0 -6
- package/components/identity.roles/manifest.toa.yaml +1 -0
- package/documentation/io.md +56 -0
- package/documentation/query.md +9 -7
- package/documentation/tree.md +22 -4
- package/features/access.feature +11 -1
- package/features/annotation.feature +1 -0
- package/features/body.feature +1 -0
- package/features/cache.feature +3 -0
- package/features/directives.feature +2 -0
- package/features/dynamic.feature +14 -7
- package/features/errors.feature +3 -2
- package/features/etag.feature +1 -0
- package/features/identity.basic.feature +23 -0
- package/features/identity.federation.feature +3 -5
- package/features/identity.roles.feature +1 -0
- package/features/identity.tokens.feature +3 -0
- package/features/io.feature +167 -0
- package/features/octets.entries.feature +2 -0
- package/features/octets.feature +2 -0
- package/features/octets.meta.feature +4 -3
- package/features/octets.workflows.feature +1 -0
- package/features/queries.feature +9 -1
- package/features/response.feature +3 -0
- package/features/routes.feature +17 -10
- package/features/steps/components/pots/manifest.toa.yaml +2 -0
- package/features/steps/components/users/manifest.toa.yaml +1 -0
- package/features/steps/components/users.properties/manifest.toa.yaml +1 -0
- package/features/timing.feature +23 -0
- package/features/vary.feature +33 -3
- package/package.json +7 -7
- package/schemas/io/input.cos.yaml +3 -0
- package/schemas/io/message.cos.yaml +5 -0
- package/schemas/io/output.cos.yaml +5 -0
- package/source/Gateway.ts +4 -4
- package/source/HTTP/Server.ts +2 -2
- package/source/HTTP/messages.ts +1 -1
- package/source/directives/auth/Authorization.ts +3 -3
- package/source/directives/index.ts +4 -3
- package/source/directives/io/Directive.ts +11 -0
- package/source/directives/io/IO.ts +43 -0
- package/source/directives/io/Input.ts +50 -0
- package/source/directives/io/Message.ts +1 -0
- package/source/directives/io/Output.ts +69 -0
- package/source/directives/io/index.ts +3 -0
- package/source/directives/io/schemas.ts +12 -0
- package/source/directives/octets/Context.ts +4 -3
- package/source/directives/octets/Delete.ts +4 -2
- package/source/directives/octets/Directive.ts +10 -0
- package/source/directives/octets/Fetch.ts +4 -3
- package/source/directives/octets/List.ts +4 -2
- package/source/directives/octets/Octets.ts +3 -2
- package/source/directives/octets/Permute.ts +4 -3
- package/source/directives/octets/Store.ts +4 -2
- package/source/directives/octets/Workflow.ts +10 -3
- package/source/directives/octets/types.ts +0 -7
- package/source/directives/vary/embeddings/Header.ts +8 -6
- package/source/root.ts +5 -0
- package/transpiled/Gateway.js +4 -4
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Server.js +2 -2
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/messages.js +1 -1
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/directives/auth/Authorization.js +3 -3
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/index.js +4 -3
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/io/Directive.d.ts +8 -0
- package/transpiled/directives/io/Directive.js +3 -0
- package/transpiled/directives/io/Directive.js.map +1 -0
- package/transpiled/directives/io/IO.d.ts +9 -0
- package/transpiled/directives/io/IO.js +33 -0
- package/transpiled/directives/io/IO.js.map +1 -0
- package/transpiled/directives/io/Input.d.ts +11 -0
- package/transpiled/directives/io/Input.js +63 -0
- package/transpiled/directives/io/Input.js.map +1 -0
- package/transpiled/directives/io/Message.d.ts +1 -0
- package/transpiled/directives/io/Message.js +3 -0
- package/transpiled/directives/io/Message.js.map +1 -0
- package/transpiled/directives/io/Output.d.ts +13 -0
- package/transpiled/directives/io/Output.js +76 -0
- package/transpiled/directives/io/Output.js.map +1 -0
- package/transpiled/directives/io/index.d.ts +2 -0
- package/transpiled/directives/io/index.js +6 -0
- package/transpiled/directives/io/index.js.map +1 -0
- package/transpiled/directives/io/schemas.d.ts +7 -0
- package/transpiled/directives/io/schemas.js +14 -0
- package/transpiled/directives/io/schemas.js.map +1 -0
- package/transpiled/directives/octets/Context.d.ts +3 -3
- package/transpiled/directives/octets/Context.js +4 -2
- package/transpiled/directives/octets/Context.js.map +1 -1
- package/transpiled/directives/octets/Delete.d.ts +3 -2
- package/transpiled/directives/octets/Delete.js +3 -1
- package/transpiled/directives/octets/Delete.js.map +1 -1
- package/transpiled/directives/octets/Directive.d.ts +8 -0
- package/transpiled/directives/octets/Directive.js +8 -0
- package/transpiled/directives/octets/Directive.js.map +1 -0
- package/transpiled/directives/octets/Fetch.d.ts +3 -2
- package/transpiled/directives/octets/Fetch.js +3 -1
- package/transpiled/directives/octets/Fetch.js.map +1 -1
- package/transpiled/directives/octets/List.d.ts +3 -2
- package/transpiled/directives/octets/List.js +3 -1
- package/transpiled/directives/octets/List.js.map +1 -1
- package/transpiled/directives/octets/Octets.d.ts +2 -1
- package/transpiled/directives/octets/Octets.js +1 -1
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/octets/Permute.d.ts +3 -2
- package/transpiled/directives/octets/Permute.js +3 -1
- package/transpiled/directives/octets/Permute.js.map +1 -1
- package/transpiled/directives/octets/Store.d.ts +3 -2
- package/transpiled/directives/octets/Store.js +3 -1
- package/transpiled/directives/octets/Store.js.map +1 -1
- package/transpiled/directives/octets/Workflow.d.ts +3 -2
- package/transpiled/directives/octets/Workflow.js +9 -2
- package/transpiled/directives/octets/Workflow.js.map +1 -1
- package/transpiled/directives/octets/types.d.ts +0 -5
- package/transpiled/directives/vary/embeddings/Header.js +8 -6
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
- package/transpiled/root.js +5 -0
- package/transpiled/root.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Feature: IO restrictions
|
|
2
|
+
|
|
3
|
+
Background:
|
|
4
|
+
Given the `pots` database contains:
|
|
5
|
+
| _id | title | volume | temperature |
|
|
6
|
+
| 4c4759e6f9c74da989d64511df42d6f4 | First pot | 100 | 80 |
|
|
7
|
+
| 99988d785d7d445cad45dbf8531f560b | Second pot | 200 | 30 |
|
|
8
|
+
|
|
9
|
+
Scenario: Output is omitted by default
|
|
10
|
+
Given the `pots` is running with the following manifest:
|
|
11
|
+
"""yaml
|
|
12
|
+
exposition:
|
|
13
|
+
/:
|
|
14
|
+
GET: enumerate
|
|
15
|
+
/:id:
|
|
16
|
+
GET: observe
|
|
17
|
+
"""
|
|
18
|
+
When the following request is received:
|
|
19
|
+
"""
|
|
20
|
+
GET /pots/4c4759e6f9c74da989d64511df42d6f4/ HTTP/1.1
|
|
21
|
+
"""
|
|
22
|
+
Then the following reply is sent:
|
|
23
|
+
"""
|
|
24
|
+
200 OK
|
|
25
|
+
content-length: 0
|
|
26
|
+
"""
|
|
27
|
+
When the following request is received:
|
|
28
|
+
"""
|
|
29
|
+
GET /pots/ HTTP/1.1
|
|
30
|
+
accept: application/yaml
|
|
31
|
+
"""
|
|
32
|
+
Then the following reply is sent:
|
|
33
|
+
"""
|
|
34
|
+
200 OK
|
|
35
|
+
content-length: 0
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
Scenario: Output is omitted by intention
|
|
39
|
+
Given the `pots` is running with the following manifest:
|
|
40
|
+
"""yaml
|
|
41
|
+
exposition:
|
|
42
|
+
/:id:
|
|
43
|
+
io:output: false
|
|
44
|
+
GET: observe
|
|
45
|
+
"""
|
|
46
|
+
When the following request is received:
|
|
47
|
+
"""
|
|
48
|
+
GET /pots/4c4759e6f9c74da989d64511df42d6f4/ HTTP/1.1
|
|
49
|
+
accept: application/yaml
|
|
50
|
+
"""
|
|
51
|
+
Then the following reply is sent:
|
|
52
|
+
"""
|
|
53
|
+
200 OK
|
|
54
|
+
content-length: 0
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
Scenario: Output permissions
|
|
58
|
+
Given the `pots` is running with the following manifest:
|
|
59
|
+
"""yaml
|
|
60
|
+
exposition:
|
|
61
|
+
/:
|
|
62
|
+
io:output: [id, volume]
|
|
63
|
+
GET: enumerate
|
|
64
|
+
/:id:
|
|
65
|
+
GET: observe
|
|
66
|
+
"""
|
|
67
|
+
When the following request is received:
|
|
68
|
+
"""
|
|
69
|
+
GET /pots/4c4759e6f9c74da989d64511df42d6f4/ HTTP/1.1
|
|
70
|
+
accept: application/yaml
|
|
71
|
+
"""
|
|
72
|
+
Then the following reply is sent:
|
|
73
|
+
"""
|
|
74
|
+
200 OK
|
|
75
|
+
|
|
76
|
+
id: 4c4759e6f9c74da989d64511df42d6f4
|
|
77
|
+
volume: 100
|
|
78
|
+
"""
|
|
79
|
+
And the reply does not contain:
|
|
80
|
+
"""
|
|
81
|
+
title:
|
|
82
|
+
temperature:
|
|
83
|
+
"""
|
|
84
|
+
When the following request is received:
|
|
85
|
+
"""
|
|
86
|
+
GET /pots/ HTTP/1.1
|
|
87
|
+
accept: application/yaml
|
|
88
|
+
"""
|
|
89
|
+
Then the following reply is sent:
|
|
90
|
+
"""
|
|
91
|
+
200 OK
|
|
92
|
+
content-type: application/yaml
|
|
93
|
+
|
|
94
|
+
- id: 4c4759e6f9c74da989d64511df42d6f4
|
|
95
|
+
volume: 100
|
|
96
|
+
- id: 99988d785d7d445cad45dbf8531f560b
|
|
97
|
+
volume: 200
|
|
98
|
+
"""
|
|
99
|
+
And the reply does not contain:
|
|
100
|
+
"""
|
|
101
|
+
title:
|
|
102
|
+
temperature:
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
Scenario: Input is unrestricted by default
|
|
106
|
+
Given the `pots` is running with the following manifest:
|
|
107
|
+
"""yaml
|
|
108
|
+
exposition:
|
|
109
|
+
/:
|
|
110
|
+
io:output: true
|
|
111
|
+
POST: create
|
|
112
|
+
"""
|
|
113
|
+
When the following request is received:
|
|
114
|
+
"""
|
|
115
|
+
POST /pots/ HTTP/1.1
|
|
116
|
+
accept: application/yaml
|
|
117
|
+
content-type: application/yaml
|
|
118
|
+
|
|
119
|
+
title: Hello
|
|
120
|
+
volume: 1.5
|
|
121
|
+
temperature: 80
|
|
122
|
+
"""
|
|
123
|
+
Then the following reply is sent:
|
|
124
|
+
"""
|
|
125
|
+
201 Created
|
|
126
|
+
|
|
127
|
+
title: Hello
|
|
128
|
+
volume: 1.5
|
|
129
|
+
temperature: 80
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
Scenario: Input permissions
|
|
133
|
+
Given the `pots` is running with the following manifest:
|
|
134
|
+
"""yaml
|
|
135
|
+
exposition:
|
|
136
|
+
/:
|
|
137
|
+
io:input: [title, volume]
|
|
138
|
+
POST: create
|
|
139
|
+
"""
|
|
140
|
+
When the following request is received:
|
|
141
|
+
"""
|
|
142
|
+
POST /pots/ HTTP/1.1
|
|
143
|
+
accept: text/plain
|
|
144
|
+
content-type: application/yaml
|
|
145
|
+
|
|
146
|
+
title: Hello
|
|
147
|
+
volume: 1.5
|
|
148
|
+
temperature: 80
|
|
149
|
+
"""
|
|
150
|
+
Then the following reply is sent:
|
|
151
|
+
"""
|
|
152
|
+
400 Bad Request
|
|
153
|
+
|
|
154
|
+
Unexpected input: temperature
|
|
155
|
+
"""
|
|
156
|
+
When the following request is received:
|
|
157
|
+
"""
|
|
158
|
+
POST /pots/ HTTP/1.1
|
|
159
|
+
content-type: application/yaml
|
|
160
|
+
|
|
161
|
+
title: Hello
|
|
162
|
+
volume: 1.5
|
|
163
|
+
"""
|
|
164
|
+
Then the following reply is sent:
|
|
165
|
+
"""
|
|
166
|
+
201 Created
|
|
167
|
+
"""
|
|
@@ -4,6 +4,7 @@ Feature: Accessing entries
|
|
|
4
4
|
Given the annotation:
|
|
5
5
|
"""yaml
|
|
6
6
|
/:
|
|
7
|
+
io:output: true
|
|
7
8
|
auth:anonymous: true
|
|
8
9
|
octets:context: octets
|
|
9
10
|
POST:
|
|
@@ -50,6 +51,7 @@ Feature: Accessing entries
|
|
|
50
51
|
Given the annotation:
|
|
51
52
|
"""yaml
|
|
52
53
|
/:
|
|
54
|
+
io:output: true
|
|
53
55
|
auth:anonymous: true
|
|
54
56
|
octets:context: octets
|
|
55
57
|
POST:
|
package/features/octets.feature
CHANGED
|
@@ -4,6 +4,7 @@ Feature: Octets directive family
|
|
|
4
4
|
Given the annotation:
|
|
5
5
|
"""yaml
|
|
6
6
|
/:
|
|
7
|
+
io:output: true
|
|
7
8
|
auth:anonymous: true
|
|
8
9
|
octets:context: octets
|
|
9
10
|
POST:
|
|
@@ -238,6 +239,7 @@ Feature: Octets directive family
|
|
|
238
239
|
Given the annotation:
|
|
239
240
|
"""yaml
|
|
240
241
|
/:
|
|
242
|
+
io:output: true
|
|
241
243
|
auth:anonymous: true
|
|
242
244
|
octets:context: octets
|
|
243
245
|
POST:
|
|
@@ -5,6 +5,7 @@ Feature: Octets `content-meta` header
|
|
|
5
5
|
And the annotation:
|
|
6
6
|
"""yaml
|
|
7
7
|
/:
|
|
8
|
+
io:output: true
|
|
8
9
|
auth:anonymous: true
|
|
9
10
|
octets:context: octets
|
|
10
11
|
/*:
|
|
@@ -55,11 +56,11 @@ Feature: Octets `content-meta` header
|
|
|
55
56
|
When the following request is received:
|
|
56
57
|
"""
|
|
57
58
|
OPTIONS / HTTP/1.1
|
|
58
|
-
origin:
|
|
59
|
+
origin: https://example.com
|
|
59
60
|
"""
|
|
60
61
|
Then the following reply is sent:
|
|
61
62
|
"""
|
|
62
63
|
204 No Content
|
|
63
|
-
access-control-allow-origin:
|
|
64
|
-
access-control-allow-headers: accept, authorization, content-type, content-meta
|
|
64
|
+
access-control-allow-origin: https://example.com
|
|
65
|
+
access-control-allow-headers: accept, authorization, content-type, etag, if-match, if-none-match, content-meta
|
|
65
66
|
"""
|
package/features/queries.feature
CHANGED
|
@@ -13,6 +13,7 @@ Feature: Queries
|
|
|
13
13
|
"""yaml
|
|
14
14
|
exposition:
|
|
15
15
|
/pot:
|
|
16
|
+
io:output: true
|
|
16
17
|
GET: observe
|
|
17
18
|
"""
|
|
18
19
|
When the following request is received:
|
|
@@ -35,6 +36,7 @@ Feature: Queries
|
|
|
35
36
|
"""yaml
|
|
36
37
|
exposition:
|
|
37
38
|
/:
|
|
39
|
+
io:output: true
|
|
38
40
|
GET: enumerate
|
|
39
41
|
"""
|
|
40
42
|
When the following request is received:
|
|
@@ -60,6 +62,7 @@ Feature: Queries
|
|
|
60
62
|
"""yaml
|
|
61
63
|
exposition:
|
|
62
64
|
/:
|
|
65
|
+
io:output: true
|
|
63
66
|
GET: enumerate
|
|
64
67
|
"""
|
|
65
68
|
When the following request is received:
|
|
@@ -85,6 +88,7 @@ Feature: Queries
|
|
|
85
88
|
"""yaml
|
|
86
89
|
exposition:
|
|
87
90
|
/:
|
|
91
|
+
io:output: true
|
|
88
92
|
GET: enumerate
|
|
89
93
|
"""
|
|
90
94
|
When the following request is received:
|
|
@@ -110,6 +114,7 @@ Feature: Queries
|
|
|
110
114
|
"""yaml
|
|
111
115
|
exposition:
|
|
112
116
|
/:id:
|
|
117
|
+
io:output: true
|
|
113
118
|
GET: observe
|
|
114
119
|
"""
|
|
115
120
|
When the following request is received:
|
|
@@ -127,11 +132,12 @@ Feature: Queries
|
|
|
127
132
|
volume: 200
|
|
128
133
|
"""
|
|
129
134
|
|
|
130
|
-
Scenario: Request to a route with predefined
|
|
135
|
+
Scenario: Request to a route with predefined criteria
|
|
131
136
|
Given the `pots` is running with the following manifest:
|
|
132
137
|
"""yaml
|
|
133
138
|
exposition:
|
|
134
139
|
/big:
|
|
140
|
+
io:output: true
|
|
135
141
|
GET:
|
|
136
142
|
endpoint: enumerate
|
|
137
143
|
query:
|
|
@@ -160,6 +166,7 @@ Feature: Queries
|
|
|
160
166
|
"""yaml
|
|
161
167
|
exposition:
|
|
162
168
|
/big:
|
|
169
|
+
io:output: true
|
|
163
170
|
GET:
|
|
164
171
|
endpoint: enumerate
|
|
165
172
|
query:
|
|
@@ -186,6 +193,7 @@ Feature: Queries
|
|
|
186
193
|
"""yaml
|
|
187
194
|
exposition:
|
|
188
195
|
/hottest2:
|
|
196
|
+
io:output: true
|
|
189
197
|
GET:
|
|
190
198
|
endpoint: enumerate
|
|
191
199
|
query:
|
|
@@ -4,6 +4,7 @@ Feature: Response
|
|
|
4
4
|
Given the annotation:
|
|
5
5
|
"""yaml
|
|
6
6
|
/:
|
|
7
|
+
io:output: true
|
|
7
8
|
GET:
|
|
8
9
|
anonymous: true
|
|
9
10
|
dev:stub: hello
|
|
@@ -25,6 +26,7 @@ Feature: Response
|
|
|
25
26
|
"""yaml
|
|
26
27
|
exposition:
|
|
27
28
|
/:
|
|
29
|
+
io:output: true
|
|
28
30
|
GET: error
|
|
29
31
|
"""
|
|
30
32
|
When the following request is received:
|
|
@@ -46,6 +48,7 @@ Feature: Response
|
|
|
46
48
|
"""yaml
|
|
47
49
|
exposition:
|
|
48
50
|
/:
|
|
51
|
+
io:output: true
|
|
49
52
|
GET: error
|
|
50
53
|
"""
|
|
51
54
|
When the following request is received:
|
package/features/routes.feature
CHANGED
|
@@ -6,12 +6,14 @@ Feature: Routes
|
|
|
6
6
|
namespace: basic
|
|
7
7
|
|
|
8
8
|
exposition:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
/:
|
|
10
|
+
io:output: true
|
|
11
|
+
/strict:
|
|
12
|
+
GET:
|
|
13
|
+
endpoint: greet
|
|
14
|
+
/shortcuts:
|
|
15
|
+
/operation:
|
|
16
|
+
GET: greet
|
|
15
17
|
"""
|
|
16
18
|
When the following request is received:
|
|
17
19
|
"""
|
|
@@ -34,6 +36,7 @@ Feature: Routes
|
|
|
34
36
|
"""yaml
|
|
35
37
|
exposition:
|
|
36
38
|
/:
|
|
39
|
+
io:output: true
|
|
37
40
|
GET: greet
|
|
38
41
|
"""
|
|
39
42
|
When the following request is received:
|
|
@@ -52,10 +55,12 @@ Feature: Routes
|
|
|
52
55
|
Given the `greeter` is running with the following manifest:
|
|
53
56
|
"""yaml
|
|
54
57
|
exposition:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
/:
|
|
59
|
+
io:output: true
|
|
60
|
+
/*:
|
|
61
|
+
GET: greet
|
|
62
|
+
/foo/*/bar:
|
|
63
|
+
GET: greet
|
|
59
64
|
"""
|
|
60
65
|
When the following request is received:
|
|
61
66
|
"""
|
|
@@ -94,12 +99,14 @@ Feature: Routes
|
|
|
94
99
|
"""yaml
|
|
95
100
|
exposition:
|
|
96
101
|
/:
|
|
102
|
+
io:output: true
|
|
97
103
|
POST: create
|
|
98
104
|
"""
|
|
99
105
|
And the `users.properties` is running with the following manifest:
|
|
100
106
|
"""yaml
|
|
101
107
|
exposition:
|
|
102
108
|
/:id:
|
|
109
|
+
io:output: true
|
|
103
110
|
GET: observe
|
|
104
111
|
"""
|
|
105
112
|
When the following request is received:
|
package/features/timing.feature
CHANGED
|
@@ -41,3 +41,26 @@ Feature: Server timing
|
|
|
41
41
|
201 Created
|
|
42
42
|
server-timing:
|
|
43
43
|
"""
|
|
44
|
+
|
|
45
|
+
Scenario: Octets timing
|
|
46
|
+
Given the annotation:
|
|
47
|
+
"""yaml
|
|
48
|
+
trace: true
|
|
49
|
+
/:
|
|
50
|
+
io:output: true
|
|
51
|
+
auth:anonymous: true
|
|
52
|
+
octets:context: octets
|
|
53
|
+
POST:
|
|
54
|
+
octets:store: ~
|
|
55
|
+
"""
|
|
56
|
+
When the stream of `lenna.png` is received with the following headers:
|
|
57
|
+
"""
|
|
58
|
+
POST / HTTP/1.1
|
|
59
|
+
content-type: application/octet-stream
|
|
60
|
+
"""
|
|
61
|
+
# to debug, break it and look at the console
|
|
62
|
+
Then the following reply is sent:
|
|
63
|
+
"""
|
|
64
|
+
201 Created
|
|
65
|
+
server-timing:
|
|
66
|
+
"""
|
package/features/vary.feature
CHANGED
|
@@ -5,6 +5,7 @@ Feature: The Vary directive family
|
|
|
5
5
|
"""yaml
|
|
6
6
|
exposition:
|
|
7
7
|
/:
|
|
8
|
+
io:output: true
|
|
8
9
|
vary:languages: [en, fr]
|
|
9
10
|
GET:
|
|
10
11
|
vary:embed:
|
|
@@ -43,6 +44,7 @@ Feature: The Vary directive family
|
|
|
43
44
|
"""yaml
|
|
44
45
|
exposition:
|
|
45
46
|
/:
|
|
47
|
+
io:output: true
|
|
46
48
|
GET:
|
|
47
49
|
anonymous: true
|
|
48
50
|
vary:embed:
|
|
@@ -62,12 +64,12 @@ Feature: The Vary directive family
|
|
|
62
64
|
content-language: fr
|
|
63
65
|
"""
|
|
64
66
|
|
|
65
|
-
|
|
66
67
|
Scenario: Embedding a value of an arbitrary header
|
|
67
68
|
Given the `echo` is running with the following manifest:
|
|
68
69
|
"""yaml
|
|
69
70
|
exposition:
|
|
70
71
|
/:
|
|
72
|
+
io:output: true
|
|
71
73
|
GET:
|
|
72
74
|
vary:embed:
|
|
73
75
|
name: :foo
|
|
@@ -88,11 +90,38 @@ Feature: The Vary directive family
|
|
|
88
90
|
Hello bar
|
|
89
91
|
"""
|
|
90
92
|
|
|
93
|
+
Scenario: Embedding a `host` header value
|
|
94
|
+
Given the `echo` is running with the following manifest:
|
|
95
|
+
"""yaml
|
|
96
|
+
exposition:
|
|
97
|
+
/:
|
|
98
|
+
io:output: true
|
|
99
|
+
GET:
|
|
100
|
+
vary:embed:
|
|
101
|
+
name: :Host
|
|
102
|
+
endpoint: compute
|
|
103
|
+
"""
|
|
104
|
+
When the following request is received:
|
|
105
|
+
"""
|
|
106
|
+
GET /echo/ HTTP/1.1
|
|
107
|
+
accept: application/yaml
|
|
108
|
+
foo: bar
|
|
109
|
+
"""
|
|
110
|
+
Then the following reply is sent:
|
|
111
|
+
"""
|
|
112
|
+
200 OK
|
|
113
|
+
content-type: application/yaml
|
|
114
|
+
vary: accept
|
|
115
|
+
|
|
116
|
+
Hello 127.0.0.1:8000
|
|
117
|
+
"""
|
|
118
|
+
|
|
91
119
|
Scenario Outline: Embedding a value from the list of options
|
|
92
120
|
Given the `echo` is running with the following manifest:
|
|
93
121
|
"""yaml
|
|
94
122
|
exposition:
|
|
95
123
|
/:
|
|
124
|
+
io:output: true
|
|
96
125
|
vary:languages: [en, fr]
|
|
97
126
|
GET:
|
|
98
127
|
vary:embed:
|
|
@@ -127,6 +156,7 @@ Feature: The Vary directive family
|
|
|
127
156
|
"""yaml
|
|
128
157
|
exposition:
|
|
129
158
|
/:
|
|
159
|
+
io:output: true
|
|
130
160
|
vary:languages: [en, fr]
|
|
131
161
|
GET:
|
|
132
162
|
vary:embed:
|
|
@@ -140,11 +170,11 @@ Feature: The Vary directive family
|
|
|
140
170
|
When the following request is received:
|
|
141
171
|
"""
|
|
142
172
|
OPTIONS / HTTP/1.1
|
|
143
|
-
origin:
|
|
173
|
+
origin: https://example.com
|
|
144
174
|
access-control-request-headers: whatever
|
|
145
175
|
"""
|
|
146
176
|
Then the following reply is sent:
|
|
147
177
|
"""
|
|
148
178
|
204 No Content
|
|
149
|
-
access-control-allow-headers: accept, authorization, content-type, accept-language, foo, bar
|
|
179
|
+
access-control-allow-headers: accept, authorization, content-type, etag, if-match, if-none-match, accept-language, foo, bar
|
|
150
180
|
"""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.exposition",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
21
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
22
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
20
|
+
"@toa.io/core": "1.0.0-alpha.7",
|
|
21
|
+
"@toa.io/generic": "1.0.0-alpha.7",
|
|
22
|
+
"@toa.io/schemas": "1.0.0-alpha.7",
|
|
23
23
|
"bcryptjs": "2.4.3",
|
|
24
24
|
"error-value": "0.3.0",
|
|
25
25
|
"js-yaml": "4.1.0",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"features": "cucumber-js"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@toa.io/agent": "1.0.0-alpha.
|
|
47
|
-
"@toa.io/extensions.storages": "1.0.0-alpha.
|
|
46
|
+
"@toa.io/agent": "1.0.0-alpha.7",
|
|
47
|
+
"@toa.io/extensions.storages": "1.0.0-alpha.7",
|
|
48
48
|
"@types/bcryptjs": "2.4.3",
|
|
49
49
|
"@types/cors": "2.8.13",
|
|
50
50
|
"@types/negotiator": "0.6.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "4f5ac0bc342d4b7bd469fbe5c74266f050b55c9f"
|
|
53
53
|
}
|
package/source/Gateway.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class Gateway extends Connector {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
public async process (context: http.Context): Promise<http.OutgoingMessage> {
|
|
25
|
-
const interception = await context.timing.capture('
|
|
25
|
+
const interception = await context.timing.capture('intercept',
|
|
26
26
|
this.interceptor.intercept(context))
|
|
27
27
|
|
|
28
28
|
if (interception !== null)
|
|
@@ -43,13 +43,13 @@ export class Gateway extends Connector {
|
|
|
43
43
|
|
|
44
44
|
const method = node.methods[context.request.method]
|
|
45
45
|
|
|
46
|
-
const interruption = await context.timing.capture('
|
|
46
|
+
const interruption = await context.timing.capture('preflight',
|
|
47
47
|
method.directives.preflight(context, parameters))
|
|
48
48
|
|
|
49
49
|
const response = interruption ??
|
|
50
|
-
await context.timing.capture('
|
|
50
|
+
await context.timing.capture('call', this.call(method, context, parameters))
|
|
51
51
|
|
|
52
|
-
await context.timing.capture('
|
|
52
|
+
await context.timing.capture('settle', method.directives.settle(context, response))
|
|
53
53
|
|
|
54
54
|
return response
|
|
55
55
|
}
|
package/source/HTTP/Server.ts
CHANGED
|
@@ -102,7 +102,7 @@ export class Server extends Connector {
|
|
|
102
102
|
else
|
|
103
103
|
status = 200
|
|
104
104
|
|
|
105
|
-
response.statusCode = status
|
|
105
|
+
response.statusCode = message.status = status
|
|
106
106
|
write(context, response, message)
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -116,7 +116,7 @@ export class Server extends Connector {
|
|
|
116
116
|
? exception.status
|
|
117
117
|
: 500
|
|
118
118
|
|
|
119
|
-
const message: OutgoingMessage = {}
|
|
119
|
+
const message: OutgoingMessage = { status: response.statusCode }
|
|
120
120
|
const verbose = exception instanceof ClientError || this.properties.debug
|
|
121
121
|
|
|
122
122
|
if (verbose)
|
package/source/HTTP/messages.ts
CHANGED
|
@@ -29,7 +29,7 @@ export async function read (context: Context): Promise<any> {
|
|
|
29
29
|
throw new UnsupportedMediaType()
|
|
30
30
|
|
|
31
31
|
const format = formats[type]
|
|
32
|
-
const buf = await context.timing.capture('
|
|
32
|
+
const buf = await context.timing.capture('buffer', buffer(context.request))
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
35
|
return format.decode(buf)
|
|
@@ -37,10 +37,10 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
|
|
|
37
37
|
private bans: Component | null = null
|
|
38
38
|
|
|
39
39
|
public create (name: string, value: any, remotes: Remotes): Directive {
|
|
40
|
-
assert.ok(name in
|
|
40
|
+
assert.ok(name in constructors,
|
|
41
41
|
`Directive '${name}' is not provided by the '${this.name}' family.`)
|
|
42
42
|
|
|
43
|
-
const Class =
|
|
43
|
+
const Class = constructors[name]
|
|
44
44
|
|
|
45
45
|
for (const name of REMOTES)
|
|
46
46
|
this.discovery[name] ??= remotes.discover('identity', name)
|
|
@@ -132,7 +132,7 @@ export class Authorization implements DirectiveFamily<Directive, Extension> {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const
|
|
135
|
+
const constructors: Record<string, new (value: any, argument?: any) => Directive> = {
|
|
136
136
|
anonymous: Anonymous,
|
|
137
137
|
id: Id,
|
|
138
138
|
role: Role,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { dev } from './dev'
|
|
2
1
|
import { authorization } from './auth'
|
|
3
2
|
import { cache } from './cache'
|
|
4
|
-
import { octets } from './octets'
|
|
5
3
|
import { cors } from './cors'
|
|
4
|
+
import { dev } from './dev'
|
|
5
|
+
import { octets } from './octets'
|
|
6
|
+
import { io } from './io'
|
|
6
7
|
import { vary } from './vary'
|
|
7
8
|
import type { DirectiveFamily } from '../RTD'
|
|
8
9
|
import type { Interceptor } from '../Interception'
|
|
9
10
|
|
|
10
|
-
export const families: DirectiveFamily[] = [authorization,
|
|
11
|
+
export const families: DirectiveFamily[] = [authorization, io, cache, vary, octets, dev]
|
|
11
12
|
export const interceptors: Interceptor[] = [cors]
|