@toa.io/extensions.exposition 1.0.0-alpha.4 → 1.0.0-alpha.6
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/cors.feature +2 -2
- package/features/directives.feature +2 -0
- package/features/dynamic.feature +14 -7
- package/features/errors.feature +3 -2
- package/features/etag.feature +12 -1
- 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/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/Context.ts +6 -4
- package/source/Directive.test.ts +4 -4
- package/source/Directive.ts +7 -33
- package/source/Endpoint.ts +41 -6
- package/source/Factory.ts +10 -4
- package/source/Gateway.ts +4 -29
- package/source/HTTP/Server.ts +2 -2
- package/source/RTD/Context.ts +7 -10
- package/source/RTD/Directives.ts +28 -4
- package/source/RTD/Endpoint.ts +6 -4
- package/source/RTD/Match.ts +2 -7
- package/source/RTD/Method.ts +7 -13
- package/source/RTD/Node.ts +13 -14
- package/source/RTD/Tree.ts +17 -16
- package/source/RTD/factory.ts +2 -5
- package/source/directives/auth/Authorization.ts +5 -6
- package/source/directives/cache/Cache.ts +2 -2
- package/source/directives/cors/CORS.ts +13 -7
- package/source/directives/dev/Development.ts +3 -3
- package/source/directives/index.ts +5 -4
- 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/Octets.ts +2 -3
- package/source/directives/octets/Store.ts +8 -2
- package/source/directives/vary/Vary.ts +2 -2
- package/source/directives/vary/embeddings/Header.ts +8 -6
- package/source/directives/vary/embeddings/Language.ts +1 -1
- package/source/root.ts +5 -0
- package/transpiled/Context.d.ts +6 -4
- package/transpiled/Directive.d.ts +4 -17
- package/transpiled/Directive.js +0 -3
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Endpoint.d.ts +5 -3
- package/transpiled/Endpoint.js +29 -4
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +5 -1
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +1 -4
- package/transpiled/Gateway.js +1 -17
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Server.js +2 -2
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/RTD/Context.d.ts +7 -6
- package/transpiled/RTD/Directives.d.ts +19 -4
- package/transpiled/RTD/Endpoint.d.ts +6 -4
- package/transpiled/RTD/Match.d.ts +2 -4
- package/transpiled/RTD/Method.d.ts +7 -7
- package/transpiled/RTD/Method.js.map +1 -1
- package/transpiled/RTD/Node.d.ts +4 -6
- package/transpiled/RTD/Node.js +2 -1
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Tree.d.ts +6 -6
- package/transpiled/RTD/Tree.js +4 -1
- package/transpiled/RTD/Tree.js.map +1 -1
- package/transpiled/RTD/factory.d.ts +2 -4
- package/transpiled/RTD/factory.js.map +1 -1
- package/transpiled/directives/auth/Authorization.d.ts +2 -3
- package/transpiled/directives/auth/Authorization.js +3 -3
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/cache/Cache.d.ts +2 -2
- package/transpiled/directives/cors/CORS.d.ts +2 -3
- package/transpiled/directives/cors/CORS.js +13 -7
- package/transpiled/directives/cors/CORS.js.map +1 -1
- package/transpiled/directives/dev/Development.d.ts +3 -3
- package/transpiled/directives/dev/Development.js.map +1 -1
- package/transpiled/directives/index.d.ts +2 -2
- 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/Octets.d.ts +2 -3
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/octets/Store.js +7 -2
- package/transpiled/directives/octets/Store.js.map +1 -1
- package/transpiled/directives/vary/Vary.d.ts +2 -2
- package/transpiled/directives/vary/embeddings/Header.js +8 -6
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Language.js +1 -1
- package/transpiled/directives/vary/embeddings/Language.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/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.6",
|
|
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.6",
|
|
21
|
+
"@toa.io/generic": "1.0.0-alpha.6",
|
|
22
|
+
"@toa.io/schemas": "1.0.0-alpha.6",
|
|
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.6",
|
|
47
|
+
"@toa.io/extensions.storages": "1.0.0-alpha.6",
|
|
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": "f28d629a9477646e267a8af8479cc1bb10d62c80"
|
|
53
53
|
}
|
package/source/Context.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { type Endpoint } from './Endpoint'
|
|
2
|
-
import { type Directives } from './Directive'
|
|
3
|
-
import { type Branch } from './Branch'
|
|
4
1
|
import type * as RTD from './RTD'
|
|
5
2
|
|
|
6
|
-
export type Context = RTD.Context<
|
|
3
|
+
export type Context = RTD.Context<Extension>
|
|
4
|
+
|
|
5
|
+
interface Extension {
|
|
6
|
+
namespace: string
|
|
7
|
+
component: string
|
|
8
|
+
}
|
package/source/Directive.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { generate } from 'randomstring'
|
|
3
|
-
import { DirectivesFactory
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { DirectivesFactory } from './Directive'
|
|
4
|
+
import type { syntax, DirectiveFamily } from './RTD'
|
|
5
|
+
import type { Remotes } from './Remotes'
|
|
6
6
|
import type { Context } from './HTTP'
|
|
7
7
|
|
|
8
|
-
const families: Array<jest.MockedObjectDeep<
|
|
8
|
+
const families: Array<jest.MockedObjectDeep<DirectiveFamily>> = [
|
|
9
9
|
{
|
|
10
10
|
name: 'foo',
|
|
11
11
|
mandatory: true,
|
package/source/Directive.ts
CHANGED
|
@@ -3,10 +3,10 @@ import type { Remotes } from './Remotes'
|
|
|
3
3
|
import type { Output } from './io'
|
|
4
4
|
import type * as RTD from './RTD'
|
|
5
5
|
|
|
6
|
-
export class Directives implements RTD.Directives
|
|
7
|
-
private readonly sets: DirectiveSet[]
|
|
6
|
+
export class Directives implements RTD.Directives {
|
|
7
|
+
private readonly sets: RTD.DirectiveSet[]
|
|
8
8
|
|
|
9
|
-
public constructor (sets: DirectiveSet[]) {
|
|
9
|
+
public constructor (sets: RTD.DirectiveSet[]) {
|
|
10
10
|
this.sets = sets
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -32,18 +32,14 @@ export class Directives implements RTD.Directives<Directives> {
|
|
|
32
32
|
if (set.family.settle !== undefined)
|
|
33
33
|
await set.family.settle(set.directives, context, response)
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
public merge (directives: Directives): void {
|
|
37
|
-
this.sets.push(...directives.sets)
|
|
38
|
-
}
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
export class DirectivesFactory implements RTD.
|
|
37
|
+
export class DirectivesFactory implements RTD.DirectiveFactory {
|
|
42
38
|
private readonly remotes: Remotes
|
|
43
|
-
private readonly families: Record<string,
|
|
39
|
+
private readonly families: Record<string, RTD.DirectiveFamily> = {}
|
|
44
40
|
private readonly mandatory: string[] = []
|
|
45
41
|
|
|
46
|
-
public constructor (families:
|
|
42
|
+
public constructor (families: RTD.DirectiveFamily[], remotes: Remotes) {
|
|
47
43
|
for (const family of families) {
|
|
48
44
|
this.families[family.name] = family
|
|
49
45
|
|
|
@@ -74,7 +70,7 @@ export class DirectivesFactory implements RTD.DirectivesFactory<Directives> {
|
|
|
74
70
|
mandatory.delete(family.name)
|
|
75
71
|
}
|
|
76
72
|
|
|
77
|
-
const sets: DirectiveSet[] = []
|
|
73
|
+
const sets: RTD.DirectiveSet[] = []
|
|
78
74
|
|
|
79
75
|
for (const family of mandatory)
|
|
80
76
|
sets.push({
|
|
@@ -99,25 +95,3 @@ export const shortcuts: RTD.syntax.Shortcuts = new Map([
|
|
|
99
95
|
['rule', 'auth:rule'],
|
|
100
96
|
['incept', 'auth:incept']
|
|
101
97
|
])
|
|
102
|
-
|
|
103
|
-
export interface Family<TDirective = any, TExtension = any> {
|
|
104
|
-
readonly name: string
|
|
105
|
-
readonly mandatory: boolean
|
|
106
|
-
|
|
107
|
-
// produce: (declarations: RTD.syntax.Directive[], remotes: Remotes) => TDirective[]
|
|
108
|
-
|
|
109
|
-
create: (name: string, value: any, remotes: Remotes) => TDirective
|
|
110
|
-
|
|
111
|
-
preflight?: (directives: TDirective[],
|
|
112
|
-
request: Context & TExtension,
|
|
113
|
-
parameters: RTD.Parameter[]) => Output | Promise<Output>
|
|
114
|
-
|
|
115
|
-
settle?: (directives: TDirective[],
|
|
116
|
-
request: Context & TExtension,
|
|
117
|
-
response: OutgoingMessage) => void | Promise<void>
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
interface DirectiveSet {
|
|
121
|
-
family: Family
|
|
122
|
-
directives: any[]
|
|
123
|
-
}
|