@toa.io/extensions.exposition 1.0.0-alpha.112 → 1.0.0-alpha.114
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/features/octets.location.feature +40 -0
- package/features/octets.workflows.feature +72 -24
- package/features/steps/components/octets.tester/manifest.toa.yaml +1 -0
- package/features/steps/components/octets.tester/operations/echo.js +1 -1
- package/features/steps/components/octets.tester/operations/id.js +7 -0
- package/package.json +3 -3
- package/source/Directive.ts +10 -3
- package/source/directives/octets/Delete.ts +10 -6
- package/source/directives/octets/Put.ts +8 -2
- package/source/directives/octets/Workflow.ts +8 -2
- package/source/directives/octets/workflows/Workflow.ts +14 -6
- package/source/directives/octets/workflows/index.ts +1 -1
- package/transpiled/Directive.js +8 -3
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/directives/octets/Delete.js +7 -4
- package/transpiled/directives/octets/Delete.js.map +1 -1
- package/transpiled/directives/octets/Put.js +6 -1
- package/transpiled/directives/octets/Put.js.map +1 -1
- package/transpiled/directives/octets/Workflow.js +6 -1
- package/transpiled/directives/octets/Workflow.js.map +1 -1
- package/transpiled/directives/octets/workflows/Workflow.d.ts +6 -2
- package/transpiled/directives/octets/workflows/Workflow.js +8 -5
- package/transpiled/directives/octets/workflows/Workflow.js.map +1 -1
- package/transpiled/directives/octets/workflows/index.d.ts +1 -1
- package/transpiled/directives/octets/workflows/index.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -41,3 +41,43 @@ Feature: Octets location
|
|
|
41
41
|
| location |
|
|
42
42
|
| ./bar |
|
|
43
43
|
| /foo/bar/ |
|
|
44
|
+
|
|
45
|
+
Scenario: Executing a workflow with specified location
|
|
46
|
+
Given the `octets.tester` is running
|
|
47
|
+
And the annotation:
|
|
48
|
+
"""yaml
|
|
49
|
+
/:
|
|
50
|
+
auth:anonymous: true
|
|
51
|
+
octets:context: octets
|
|
52
|
+
POST:
|
|
53
|
+
octets:put:
|
|
54
|
+
location: /hello/world/
|
|
55
|
+
workflow:
|
|
56
|
+
echo: octets.tester.echo
|
|
57
|
+
io:output: true
|
|
58
|
+
"""
|
|
59
|
+
When the stream of `lenna.ascii` is received with the following headers:
|
|
60
|
+
"""
|
|
61
|
+
POST / HTTP/1.1
|
|
62
|
+
host: nex.toa.io
|
|
63
|
+
accept: application/yaml, multipart/yaml
|
|
64
|
+
content-type: application/octet-stream
|
|
65
|
+
"""
|
|
66
|
+
Then the following reply is sent:
|
|
67
|
+
"""
|
|
68
|
+
201 Created
|
|
69
|
+
content-type: multipart/yaml; boundary=cut
|
|
70
|
+
|
|
71
|
+
--cut
|
|
72
|
+
|
|
73
|
+
id: ${{ id }}
|
|
74
|
+
type: application/octet-stream
|
|
75
|
+
size: 8169
|
|
76
|
+
--cut
|
|
77
|
+
|
|
78
|
+
step: echo
|
|
79
|
+
status: completed
|
|
80
|
+
output:
|
|
81
|
+
path: /hello/world/${{ id }}
|
|
82
|
+
--cut--
|
|
83
|
+
"""
|
|
@@ -13,11 +13,6 @@ Feature: Octets storage workflows
|
|
|
13
13
|
- add-foo: octets.tester.foo
|
|
14
14
|
add-bar: octets.tester.bar
|
|
15
15
|
- add-baz: octets.tester.baz
|
|
16
|
-
/*:
|
|
17
|
-
io:output: true
|
|
18
|
-
GET:
|
|
19
|
-
octets:get:
|
|
20
|
-
meta: true
|
|
21
16
|
"""
|
|
22
17
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
23
18
|
"""
|
|
@@ -33,9 +28,10 @@ Feature: Octets storage workflows
|
|
|
33
28
|
|
|
34
29
|
--cut
|
|
35
30
|
|
|
36
|
-
id:
|
|
37
|
-
type: application/octet-stream
|
|
31
|
+
id: ${{ id }}
|
|
38
32
|
size: 8169
|
|
33
|
+
type: application/octet-stream
|
|
34
|
+
checksum: 10cf16b458f759e0d617f2f3d83599ff
|
|
39
35
|
--cut
|
|
40
36
|
|
|
41
37
|
step: add-foo
|
|
@@ -53,6 +49,39 @@ Feature: Octets storage workflows
|
|
|
53
49
|
--cut--
|
|
54
50
|
"""
|
|
55
51
|
|
|
52
|
+
Scenario: Composing workflow results
|
|
53
|
+
Given the `octets.tester` is running
|
|
54
|
+
And the annotation:
|
|
55
|
+
"""yaml
|
|
56
|
+
/:
|
|
57
|
+
auth:anonymous: true
|
|
58
|
+
octets:context: octets
|
|
59
|
+
POST:
|
|
60
|
+
octets:put:
|
|
61
|
+
workflow:
|
|
62
|
+
- add-foo: octets.tester.foo
|
|
63
|
+
add-bar: octets.tester.bar
|
|
64
|
+
- add-baz: octets.tester.baz
|
|
65
|
+
flow:compose:
|
|
66
|
+
checksum: $[0].checksum
|
|
67
|
+
bar: $[2].output.bar
|
|
68
|
+
"""
|
|
69
|
+
When the stream of `lenna.ascii` is received with the following headers:
|
|
70
|
+
"""
|
|
71
|
+
POST / HTTP/1.1
|
|
72
|
+
host: nex.toa.io
|
|
73
|
+
accept: application/yaml, multipart/yaml
|
|
74
|
+
content-type: application/octet-stream
|
|
75
|
+
"""
|
|
76
|
+
Then the following reply is sent:
|
|
77
|
+
"""
|
|
78
|
+
201 Created
|
|
79
|
+
content-type: application/yaml
|
|
80
|
+
|
|
81
|
+
checksum: 10cf16b458f759e0d617f2f3d83599ff
|
|
82
|
+
bar: baz
|
|
83
|
+
"""
|
|
84
|
+
|
|
56
85
|
Scenario: Getting error when running workflow on `store`
|
|
57
86
|
Given the `octets.tester` is running
|
|
58
87
|
Given the annotation:
|
|
@@ -80,7 +109,7 @@ Feature: Octets storage workflows
|
|
|
80
109
|
content-type: multipart/yaml; boundary=cut
|
|
81
110
|
|
|
82
111
|
--cut
|
|
83
|
-
id:
|
|
112
|
+
id: ${{ id }}
|
|
84
113
|
type: application/octet-stream
|
|
85
114
|
size: 8169
|
|
86
115
|
--cut
|
|
@@ -106,27 +135,32 @@ Feature: Octets storage workflows
|
|
|
106
135
|
octets:context: octets
|
|
107
136
|
POST:
|
|
108
137
|
octets:put: ~
|
|
138
|
+
io:output: true
|
|
109
139
|
/*:
|
|
110
140
|
GET:
|
|
111
141
|
octets:get: ~
|
|
112
142
|
DELETE:
|
|
113
143
|
octets:delete:
|
|
114
144
|
workflow:
|
|
115
|
-
echo: octets.tester.
|
|
145
|
+
echo: octets.tester.id
|
|
146
|
+
io:output: true
|
|
116
147
|
"""
|
|
117
148
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
118
149
|
"""
|
|
119
150
|
POST / HTTP/1.1
|
|
120
151
|
host: nex.toa.io
|
|
121
152
|
content-type: application/octet-stream
|
|
153
|
+
accept: application/yaml
|
|
122
154
|
"""
|
|
123
155
|
Then the following reply is sent:
|
|
124
156
|
"""
|
|
125
157
|
201 Created
|
|
158
|
+
|
|
159
|
+
id: ${{ id }}
|
|
126
160
|
"""
|
|
127
161
|
When the following request is received:
|
|
128
162
|
"""
|
|
129
|
-
DELETE
|
|
163
|
+
DELETE /${{ id }} HTTP/1.1
|
|
130
164
|
host: nex.toa.io
|
|
131
165
|
accept: application/yaml, multipart/yaml
|
|
132
166
|
"""
|
|
@@ -138,12 +172,12 @@ Feature: Octets storage workflows
|
|
|
138
172
|
--cut
|
|
139
173
|
step: echo
|
|
140
174
|
status: completed
|
|
141
|
-
output:
|
|
175
|
+
output: ${{ id }}
|
|
142
176
|
--cut--
|
|
143
177
|
"""
|
|
144
178
|
When the following request is received:
|
|
145
179
|
"""
|
|
146
|
-
GET
|
|
180
|
+
GET /${{ id }} HTTP/1.1
|
|
147
181
|
host: nex.toa.io
|
|
148
182
|
"""
|
|
149
183
|
Then the following reply is sent:
|
|
@@ -160,6 +194,7 @@ Feature: Octets storage workflows
|
|
|
160
194
|
octets:context: octets
|
|
161
195
|
POST:
|
|
162
196
|
octets:put: ~
|
|
197
|
+
io:output: true
|
|
163
198
|
/*:
|
|
164
199
|
GET:
|
|
165
200
|
octets:get: ~
|
|
@@ -167,20 +202,24 @@ Feature: Octets storage workflows
|
|
|
167
202
|
octets:delete:
|
|
168
203
|
workflow:
|
|
169
204
|
err: octets.tester.err
|
|
205
|
+
io:output: true
|
|
170
206
|
"""
|
|
171
207
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
172
208
|
"""
|
|
173
209
|
POST / HTTP/1.1
|
|
174
210
|
host: nex.toa.io
|
|
175
211
|
content-type: application/octet-stream
|
|
212
|
+
accept: application/yaml
|
|
176
213
|
"""
|
|
177
214
|
Then the following reply is sent:
|
|
178
215
|
"""
|
|
179
216
|
201 Created
|
|
217
|
+
|
|
218
|
+
id: ${{ id }}
|
|
180
219
|
"""
|
|
181
220
|
When the following request is received:
|
|
182
221
|
"""
|
|
183
|
-
DELETE
|
|
222
|
+
DELETE /${{ id }} HTTP/1.1
|
|
184
223
|
host: nex.toa.io
|
|
185
224
|
accept: application/yaml, multipart/yaml
|
|
186
225
|
"""
|
|
@@ -200,7 +239,7 @@ Feature: Octets storage workflows
|
|
|
200
239
|
"""
|
|
201
240
|
When the following request is received:
|
|
202
241
|
"""
|
|
203
|
-
GET
|
|
242
|
+
GET /${{ id }} HTTP/1.1
|
|
204
243
|
host: nex.toa.io
|
|
205
244
|
"""
|
|
206
245
|
Then the following reply is sent:
|
|
@@ -220,6 +259,7 @@ Feature: Octets storage workflows
|
|
|
220
259
|
octets:put:
|
|
221
260
|
workflow:
|
|
222
261
|
concat: octets.tester.concat
|
|
262
|
+
io:output: true
|
|
223
263
|
"""
|
|
224
264
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
225
265
|
"""
|
|
@@ -235,7 +275,7 @@ Feature: Octets storage workflows
|
|
|
235
275
|
|
|
236
276
|
--cut
|
|
237
277
|
|
|
238
|
-
id:
|
|
278
|
+
id: ${{ id }}
|
|
239
279
|
type: application/octet-stream
|
|
240
280
|
size: 8169
|
|
241
281
|
--cut
|
|
@@ -258,6 +298,7 @@ Feature: Octets storage workflows
|
|
|
258
298
|
octets:put:
|
|
259
299
|
workflow:
|
|
260
300
|
authority: octets.tester.authority
|
|
301
|
+
io:output: true
|
|
261
302
|
"""
|
|
262
303
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
263
304
|
"""
|
|
@@ -273,7 +314,7 @@ Feature: Octets storage workflows
|
|
|
273
314
|
|
|
274
315
|
--cut
|
|
275
316
|
|
|
276
|
-
id:
|
|
317
|
+
id: ${{ id }}
|
|
277
318
|
type: application/octet-stream
|
|
278
319
|
size: 8169
|
|
279
320
|
--cut
|
|
@@ -293,24 +334,29 @@ Feature: Octets storage workflows
|
|
|
293
334
|
octets:context: octets
|
|
294
335
|
POST:
|
|
295
336
|
octets:put: ~
|
|
337
|
+
io:output: true
|
|
296
338
|
/*:
|
|
297
339
|
DELETE:
|
|
298
340
|
octets:workflow:
|
|
299
|
-
|
|
341
|
+
id: octets.tester.id
|
|
342
|
+
io:output: true
|
|
300
343
|
"""
|
|
301
344
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
302
345
|
"""
|
|
303
346
|
POST / HTTP/1.1
|
|
304
347
|
host: nex.toa.io
|
|
305
348
|
content-type: application/octet-stream
|
|
349
|
+
accept: application/yaml
|
|
306
350
|
"""
|
|
307
351
|
Then the following reply is sent:
|
|
308
352
|
"""
|
|
309
353
|
201 Created
|
|
354
|
+
|
|
355
|
+
id: ${{ id }}
|
|
310
356
|
"""
|
|
311
357
|
When the following request is received:
|
|
312
358
|
"""
|
|
313
|
-
DELETE
|
|
359
|
+
DELETE /${{ id }} HTTP/1.1
|
|
314
360
|
host: nex.toa.io
|
|
315
361
|
accept: application/yaml, multipart/yaml
|
|
316
362
|
"""
|
|
@@ -321,9 +367,9 @@ Feature: Octets storage workflows
|
|
|
321
367
|
|
|
322
368
|
--cut
|
|
323
369
|
|
|
324
|
-
step:
|
|
370
|
+
step: id
|
|
325
371
|
status: completed
|
|
326
|
-
output:
|
|
372
|
+
output: ${{ id }}
|
|
327
373
|
|
|
328
374
|
--cut--
|
|
329
375
|
"""
|
|
@@ -340,6 +386,7 @@ Feature: Octets storage workflows
|
|
|
340
386
|
workflow:
|
|
341
387
|
- foo: octets.tester.foo
|
|
342
388
|
- yield: octets.tester.yield
|
|
389
|
+
io:output: true
|
|
343
390
|
"""
|
|
344
391
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
345
392
|
"""
|
|
@@ -355,7 +402,7 @@ Feature: Octets storage workflows
|
|
|
355
402
|
|
|
356
403
|
--cut
|
|
357
404
|
|
|
358
|
-
id:
|
|
405
|
+
id: ${{ id }}
|
|
359
406
|
type: application/octet-stream
|
|
360
407
|
|
|
361
408
|
--cut
|
|
@@ -392,6 +439,7 @@ Feature: Octets storage workflows
|
|
|
392
439
|
octets:put:
|
|
393
440
|
workflow:
|
|
394
441
|
yield: octets.tester.yex
|
|
442
|
+
io:output: true
|
|
395
443
|
"""
|
|
396
444
|
When the stream of `lenna.ascii` is received with the following headers:
|
|
397
445
|
"""
|
|
@@ -407,7 +455,7 @@ Feature: Octets storage workflows
|
|
|
407
455
|
|
|
408
456
|
--cut
|
|
409
457
|
|
|
410
|
-
id:
|
|
458
|
+
id: ${{ id }}
|
|
411
459
|
type: application/octet-stream
|
|
412
460
|
|
|
413
461
|
--cut
|
|
@@ -435,12 +483,12 @@ Feature: Octets storage workflows
|
|
|
435
483
|
/:
|
|
436
484
|
auth:anonymous: true
|
|
437
485
|
octets:context: octets
|
|
486
|
+
io:output: true
|
|
438
487
|
POST:
|
|
439
488
|
octets:put:
|
|
440
489
|
workflow:
|
|
441
490
|
foo: task:octets.tester.foo
|
|
442
491
|
/*:
|
|
443
|
-
io:output: true
|
|
444
492
|
GET:
|
|
445
493
|
octets:get:
|
|
446
494
|
meta: true
|
|
@@ -459,7 +507,7 @@ Feature: Octets storage workflows
|
|
|
459
507
|
|
|
460
508
|
--cut
|
|
461
509
|
|
|
462
|
-
id:
|
|
510
|
+
id: ${{ id }}
|
|
463
511
|
|
|
464
512
|
--cut
|
|
465
513
|
|
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.114",
|
|
4
4
|
"description": "Toa Exposition",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@toa.io/agent": "1.0.0-alpha.112",
|
|
57
|
-
"@toa.io/extensions.storages": "1.0.0-alpha.
|
|
57
|
+
"@toa.io/extensions.storages": "1.0.0-alpha.113",
|
|
58
58
|
"@types/bcryptjs": "2.4.3",
|
|
59
59
|
"@types/cors": "2.8.13",
|
|
60
60
|
"@types/http-cache-semantics": "4.0.4",
|
|
61
61
|
"@types/negotiator": "0.6.1",
|
|
62
62
|
"jest-esbuild": "0.3.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "cb31ca0e47781b5f47412f002b62591169be1a4e"
|
|
65
65
|
}
|
package/source/Directive.ts
CHANGED
|
@@ -11,17 +11,24 @@ export class Directives implements RTD.Directives {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
public async preflight (context: Context, parameters: RTD.Parameter[]): Promise<Output> {
|
|
14
|
+
let output = null
|
|
15
|
+
|
|
14
16
|
for (const set of this.sets) {
|
|
15
17
|
if (set.family.preflight === undefined)
|
|
16
18
|
continue
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const out = await set.family.preflight(set.directives, context, parameters)
|
|
21
|
+
|
|
22
|
+
if (out === null)
|
|
23
|
+
continue
|
|
19
24
|
|
|
20
25
|
if (output !== null)
|
|
21
|
-
|
|
26
|
+
throw new Error('Multiple preflight directives responded')
|
|
27
|
+
else
|
|
28
|
+
output = out
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
return
|
|
31
|
+
return output
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
public async settle (context: Context, response: OutgoingMessage): Promise<void> {
|
|
@@ -4,7 +4,7 @@ import * as schemas from './schemas'
|
|
|
4
4
|
import { Workflow } from './workflows'
|
|
5
5
|
import { Directive } from './Directive'
|
|
6
6
|
import type { Parameter } from '../../RTD'
|
|
7
|
-
import type { Unit } from './workflows'
|
|
7
|
+
import type { Unit, Location } from './workflows'
|
|
8
8
|
import type { Maybe } from '@toa.io/types'
|
|
9
9
|
import type { Component } from '@toa.io/core'
|
|
10
10
|
import type { Output } from '../../io'
|
|
@@ -17,7 +17,7 @@ export class Delete extends Directive {
|
|
|
17
17
|
|
|
18
18
|
private readonly workflow?: Workflow
|
|
19
19
|
private readonly discovery: Promise<Component>
|
|
20
|
-
private storage
|
|
20
|
+
private storage!: Component
|
|
21
21
|
|
|
22
22
|
public constructor (options: Options | null, discovery: Promise<Component>, remotes: Remotes) {
|
|
23
23
|
super()
|
|
@@ -55,8 +55,7 @@ export class Delete extends Directive {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
private async delete (storage: string, input: Input): Promise<void> {
|
|
58
|
-
|
|
59
|
-
await this.storage!.invoke('delete',
|
|
58
|
+
await this.storage.invoke('delete',
|
|
60
59
|
{
|
|
61
60
|
input: {
|
|
62
61
|
storage,
|
|
@@ -68,8 +67,13 @@ export class Delete extends Directive {
|
|
|
68
67
|
// eslint-disable-next-line max-params
|
|
69
68
|
private async * execute
|
|
70
69
|
(input: Input, storage: string, entry: Entry, parameters: Parameter[]): AsyncGenerator {
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const location: Location = {
|
|
71
|
+
storage,
|
|
72
|
+
authority: input.authority,
|
|
73
|
+
path: input.request.url
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for await (const chunk of this.workflow!.execute(location, entry, parameters)) {
|
|
73
77
|
yield chunk
|
|
74
78
|
|
|
75
79
|
if (typeof chunk === 'object' && chunk !== null && 'error' in chunk)
|
|
@@ -8,7 +8,7 @@ import { Directive } from './Directive'
|
|
|
8
8
|
import { toBytes } from './bytes'
|
|
9
9
|
import type { Readable } from 'stream'
|
|
10
10
|
import type { Parameter } from '../../RTD'
|
|
11
|
-
import type { Unit } from './workflows'
|
|
11
|
+
import type { Unit, Location } from './workflows'
|
|
12
12
|
import type { Entry } from '@toa.io/extensions.storages'
|
|
13
13
|
import type { Remotes } from '../../Remotes'
|
|
14
14
|
import type { Err } from 'error-value'
|
|
@@ -94,7 +94,13 @@ export class Put extends Directive {
|
|
|
94
94
|
|
|
95
95
|
stream.push(entry)
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const location: Location = {
|
|
98
|
+
storage,
|
|
99
|
+
authority: input.authority,
|
|
100
|
+
path: this.location ?? input.request.url
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.workflow!.execute(location, entry, parameters).pipe(stream)
|
|
98
104
|
|
|
99
105
|
return stream
|
|
100
106
|
}
|
|
@@ -2,7 +2,7 @@ import { NotFound } from '../../HTTP'
|
|
|
2
2
|
import * as schemas from './schemas'
|
|
3
3
|
import { Workflow } from './workflows'
|
|
4
4
|
import { Directive } from './Directive'
|
|
5
|
-
import type { Unit } from './workflows'
|
|
5
|
+
import type { Unit, Location } from './workflows'
|
|
6
6
|
import type { Input } from './types'
|
|
7
7
|
import type { Component } from '@toa.io/core'
|
|
8
8
|
import type { Output } from '../../io'
|
|
@@ -40,9 +40,15 @@ export class WorkflowDirective extends Directive {
|
|
|
40
40
|
if (entry instanceof Error)
|
|
41
41
|
throw new NotFound()
|
|
42
42
|
|
|
43
|
+
const location: Location = {
|
|
44
|
+
storage,
|
|
45
|
+
authority: input.authority,
|
|
46
|
+
path: input.request.url
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
return {
|
|
44
50
|
status: 202,
|
|
45
|
-
body: this.workflow.execute(
|
|
51
|
+
body: this.workflow.execute(location, entry, parameters)
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
@@ -4,7 +4,6 @@ import { Execution } from './Execution'
|
|
|
4
4
|
import type { Entry } from '@toa.io/extensions.storages'
|
|
5
5
|
import type { Context } from './Execution'
|
|
6
6
|
import type { Parameter } from '../../../RTD'
|
|
7
|
-
import type { Input } from '../types'
|
|
8
7
|
import type { Remotes } from '../../../Remotes'
|
|
9
8
|
|
|
10
9
|
export class Workflow {
|
|
@@ -19,19 +18,28 @@ export class Workflow {
|
|
|
19
18
|
this.remotes = remotes
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
public execute (input: Input, storage: string, entry: Entry, params: Parameter[]): Execution {
|
|
24
|
-
const path = posix.join(input.request.url, entry.id)
|
|
25
|
-
const authority = input.authority
|
|
21
|
+
public execute (location: Location, entry: Entry, params: Parameter[]): Execution {
|
|
26
22
|
const parameters: Record<string, string> = {}
|
|
27
23
|
|
|
28
24
|
for (const { name, value } of params)
|
|
29
25
|
parameters[name] = value
|
|
30
26
|
|
|
31
|
-
const context: Context = {
|
|
27
|
+
const context: Context = {
|
|
28
|
+
authority: location.authority,
|
|
29
|
+
storage: location.storage,
|
|
30
|
+
path: posix.join(location.path, entry.id),
|
|
31
|
+
entry,
|
|
32
|
+
parameters
|
|
33
|
+
}
|
|
32
34
|
|
|
33
35
|
return new Execution(context, this.units, this.remotes)
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
export interface Location {
|
|
40
|
+
storage: string
|
|
41
|
+
authority: string
|
|
42
|
+
path: string
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
export type Unit = Record<string, string>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Workflow, type Unit } from './Workflow'
|
|
1
|
+
export { Workflow, type Unit, type Location } from './Workflow'
|
package/transpiled/Directive.js
CHANGED
|
@@ -7,14 +7,19 @@ class Directives {
|
|
|
7
7
|
this.sets = sets;
|
|
8
8
|
}
|
|
9
9
|
async preflight(context, parameters) {
|
|
10
|
+
let output = null;
|
|
10
11
|
for (const set of this.sets) {
|
|
11
12
|
if (set.family.preflight === undefined)
|
|
12
13
|
continue;
|
|
13
|
-
const
|
|
14
|
+
const out = await set.family.preflight(set.directives, context, parameters);
|
|
15
|
+
if (out === null)
|
|
16
|
+
continue;
|
|
14
17
|
if (output !== null)
|
|
15
|
-
|
|
18
|
+
throw new Error('Multiple preflight directives responded');
|
|
19
|
+
else
|
|
20
|
+
output = out;
|
|
16
21
|
}
|
|
17
|
-
return
|
|
22
|
+
return output;
|
|
18
23
|
}
|
|
19
24
|
async settle(context, response) {
|
|
20
25
|
for (const set of this.sets)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IACJ,IAAI,CAAoB;IAEzC,YAAoB,IAAwB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,OAAgB,EAAE,UAA2B;QACnE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS;gBACpC,SAAQ;YAEV,MAAM,
|
|
1
|
+
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IACJ,IAAI,CAAoB;IAEzC,YAAoB,IAAwB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,OAAgB,EAAE,UAA2B;QACnE,IAAI,MAAM,GAAG,IAAI,CAAA;QAEjB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS;gBACpC,SAAQ;YAEV,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;YAE3E,IA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,CAAC;IACrD,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAC/B,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,OAAO,EAAE,UAAU,CAAC;IACrB,CAAC,QAAQ,EAAE,WAAW,CAAC;IACvB,CAAC,WAAW,EAAE,eAAe,CAAC;CAC/B,CAAC,CAAA"}
|
|
@@ -33,7 +33,7 @@ class Delete extends Directive_1.Directive {
|
|
|
33
33
|
targeted = true;
|
|
34
34
|
workflow;
|
|
35
35
|
discovery;
|
|
36
|
-
storage
|
|
36
|
+
storage;
|
|
37
37
|
constructor(options, discovery, remotes) {
|
|
38
38
|
super();
|
|
39
39
|
schemas.remove.validate(options);
|
|
@@ -61,7 +61,6 @@ class Delete extends Directive_1.Directive {
|
|
|
61
61
|
return output;
|
|
62
62
|
}
|
|
63
63
|
async delete(storage, input) {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
64
|
await this.storage.invoke('delete', {
|
|
66
65
|
input: {
|
|
67
66
|
storage,
|
|
@@ -71,8 +70,12 @@ class Delete extends Directive_1.Directive {
|
|
|
71
70
|
}
|
|
72
71
|
// eslint-disable-next-line max-params
|
|
73
72
|
async *execute(input, storage, entry, parameters) {
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const location = {
|
|
74
|
+
storage,
|
|
75
|
+
authority: input.authority,
|
|
76
|
+
path: input.request.url
|
|
77
|
+
};
|
|
78
|
+
for await (const chunk of this.workflow.execute(location, entry, parameters)) {
|
|
76
79
|
yield chunk;
|
|
77
80
|
if (typeof chunk === 'object' && chunk !== null && 'error' in chunk)
|
|
78
81
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../source/directives/octets/Delete.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,qCAAqC;AACrC,mDAAoC;AACpC,2CAAsC;AACtC,2CAAuC;AAUvC,MAAa,MAAO,SAAQ,qBAAS;IACnB,QAAQ,GAAG,IAAI,CAAA;IAEd,QAAQ,CAAW;IACnB,SAAS,CAAoB;IACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../source/directives/octets/Delete.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,qCAAqC;AACrC,mDAAoC;AACpC,2CAAsC;AACtC,2CAAuC;AAUvC,MAAa,MAAO,SAAQ,qBAAS;IACnB,QAAQ,GAAG,IAAI,CAAA;IAEd,QAAQ,CAAW;IACnB,SAAS,CAAoB;IACtC,OAAO,CAAY;IAE3B,YAAoB,OAAuB,EAAE,SAA6B,EAAE,OAAgB;QAC1F,KAAK,EAAE,CAAA;QACP,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAEhC,IAAI,OAAO,EAAE,QAAQ,KAAK,SAAS;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAEzD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,KAAY,EAAE,UAAuB;QACxE,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAErC,MAAM,MAAM,GAAW,EAAE,CAAA;QAEzB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAe,MAAM,EAC1D;gBACE,KAAK,EAAE;oBACL,OAAO;oBACP,IAAI,EAAE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|
|
@@ -84,7 +84,12 @@ class Put extends Directive_1.Directive {
|
|
|
84
84
|
execute(input, storage, entry, parameters) {
|
|
85
85
|
const stream = new node_stream_1.PassThrough({ objectMode: true });
|
|
86
86
|
stream.push(entry);
|
|
87
|
-
|
|
87
|
+
const location = {
|
|
88
|
+
storage,
|
|
89
|
+
authority: input.authority,
|
|
90
|
+
path: this.location ?? input.request.url
|
|
91
|
+
};
|
|
92
|
+
this.workflow.execute(location, entry, parameters).pipe(stream);
|
|
88
93
|
return stream;
|
|
89
94
|
}
|
|
90
95
|
throw(error) {
|