@toa.io/userland 1.2.0-dev.1 → 1.2.0-dev.11
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/example/components/echo/operations/signal.js +11 -3
- package/example/components/math.calculations/samples/add.yaml +1 -2
- package/example/components/math.calculations/samples/assets/ab.yaml +2 -0
- package/example/components/web/operations/get.js +4 -0
- package/example/components/web/samples/get.yaml +2 -0
- package/package.json +9 -9
- package/samples/readme.md +36 -2
- package/samples/src/.replay/.suite/operations.js +0 -1
- package/samples/src/.replay/test.js +4 -3
- package/samples/src/components.js +1 -1
- package/samples/src/context.js +1 -1
- package/samples/src/replay.js +2 -2
- package/samples/test/components.test.js +2 -2
- package/samples/test/context.test.js +2 -2
- package/samples/test/replay.test.js +0 -1
- package/samples/types/replay.d.ts +3 -3
- package/samples/types/suite.d.ts +16 -15
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class Computation {
|
|
4
|
+
#context
|
|
5
|
+
|
|
6
|
+
async mount (context) {
|
|
7
|
+
this.#context = context
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async execute () {
|
|
11
|
+
return this.#context.configuration.signal
|
|
12
|
+
}
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
exports.
|
|
15
|
+
exports.Computation = Computation
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
async function computation (_, context) {
|
|
4
4
|
const response = await context.http.dev.path.to.resource.get()
|
|
5
|
+
const type = response.headers.get('content-type')
|
|
6
|
+
|
|
7
|
+
if (type !== 'application/json') return { error: { code: 0, message: 'Unsupported media type ' + type } }
|
|
8
|
+
|
|
5
9
|
const output = await response.json()
|
|
6
10
|
|
|
7
11
|
return { output }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "1.2.0-dev.
|
|
3
|
+
"version": "1.2.0-dev.11",
|
|
4
4
|
"description": "Toa development kit",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"main": "src/index.js",
|
|
25
25
|
"types": "types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@toa.io/boot": "1.0.2-dev.
|
|
28
|
-
"@toa.io/core": "1.1.0-dev.
|
|
29
|
-
"@toa.io/filesystem": "1.0.2-dev.
|
|
30
|
-
"@toa.io/generic": "0.11.0-dev.
|
|
31
|
-
"@toa.io/norm": "1.0.2-dev.
|
|
32
|
-
"@toa.io/schemas": "0.8.4-dev.
|
|
33
|
-
"@toa.io/yaml": "0.7.6-dev.
|
|
27
|
+
"@toa.io/boot": "1.0.2-dev.11",
|
|
28
|
+
"@toa.io/core": "1.1.0-dev.11",
|
|
29
|
+
"@toa.io/filesystem": "1.0.2-dev.11",
|
|
30
|
+
"@toa.io/generic": "0.11.0-dev.11",
|
|
31
|
+
"@toa.io/norm": "1.0.2-dev.11",
|
|
32
|
+
"@toa.io/schemas": "0.8.4-dev.11",
|
|
33
|
+
"@toa.io/yaml": "0.7.6-dev.11",
|
|
34
34
|
"tap": "16.3.4"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "43f790e208d5eea38a8d3f09136dc1221d26ccc3"
|
|
37
37
|
}
|
package/samples/readme.md
CHANGED
|
@@ -92,6 +92,40 @@ context (so as required extensions). See [examples](../example/samples).
|
|
|
92
92
|
|
|
93
93
|
## Replay
|
|
94
94
|
|
|
95
|
-
Samples may be *replayed* using [`toa replay`](/runtime/cli/readme.md#replay) command.
|
|
96
|
-
|
|
97
95
|
> Replaying samples requires local deployment environment.
|
|
96
|
+
|
|
97
|
+
### CLI
|
|
98
|
+
|
|
99
|
+
Samples may be replayed using [`toa replay`](/runtime/cli/readme.md#replay) command.
|
|
100
|
+
|
|
101
|
+
See [features](/features/cli/replay.feature).
|
|
102
|
+
|
|
103
|
+
### Framework
|
|
104
|
+
|
|
105
|
+
`async components(paths: string[], options?): boolean`
|
|
106
|
+
|
|
107
|
+
Replay component samples.
|
|
108
|
+
|
|
109
|
+
`async components(paths: string[], options?): boolean`
|
|
110
|
+
|
|
111
|
+
Replay context and its components' samples.
|
|
112
|
+
|
|
113
|
+
#### Options
|
|
114
|
+
|
|
115
|
+
<dl>
|
|
116
|
+
<dt><code><strong>id</strong>: string</code></dt>
|
|
117
|
+
<dd>Replay samples for a specified component</dd>
|
|
118
|
+
|
|
119
|
+
<dt><code><strong>integration</strong>: string</code></dt>
|
|
120
|
+
<dd>Replay samples for a specified component only</dd>
|
|
121
|
+
<dd></dd>
|
|
122
|
+
|
|
123
|
+
<dt><code><strong>operation</strong>: string</code></dt>
|
|
124
|
+
<dd>Replay samples for specified operation</dd>
|
|
125
|
+
|
|
126
|
+
<dt><code><strong>title</strong>: string</code></dt>
|
|
127
|
+
<dd>Replay samples with titles matching given regexp</dd>
|
|
128
|
+
|
|
129
|
+
</dl>
|
|
130
|
+
|
|
131
|
+
See [types](types/suite.d.ts).
|
|
@@ -6,12 +6,13 @@ const replay = require('./suite')
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {toa.samples.Suite} suite
|
|
9
|
+
* @param {object} options
|
|
9
10
|
* @return {Promise<boolean>}
|
|
10
11
|
*/
|
|
11
|
-
const test = async (suite) => {
|
|
12
|
-
const
|
|
12
|
+
const test = async (suite, options) => {
|
|
13
|
+
const result = await tap.test(suite.title, options, replay.suite(suite))
|
|
13
14
|
|
|
14
|
-
return ok
|
|
15
|
+
return result === null ? false : result.ok
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
exports.test = test
|
|
@@ -7,7 +7,7 @@ const { replay } = require('./replay')
|
|
|
7
7
|
const components = async (paths, options = {}) => {
|
|
8
8
|
const suite = await load(paths, options)
|
|
9
9
|
|
|
10
|
-
return await replay(suite, paths)
|
|
10
|
+
return await replay(suite, paths, options.runner)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
exports.components = components
|
package/samples/src/context.js
CHANGED
|
@@ -15,7 +15,7 @@ const context = async (path, options = {}) => {
|
|
|
15
15
|
let ok = true
|
|
16
16
|
|
|
17
17
|
if (options.integration !== true) ok = await test.components(paths, options)
|
|
18
|
-
if (ok) ok = await replay(suite, paths)
|
|
18
|
+
if (ok) ok = await replay(suite, paths, options.runner)
|
|
19
19
|
|
|
20
20
|
return ok
|
|
21
21
|
}
|
package/samples/src/replay.js
CHANGED
|
@@ -4,10 +4,10 @@ const stage = require('@toa.io/userland/stage')
|
|
|
4
4
|
const { test } = require('./.replay')
|
|
5
5
|
|
|
6
6
|
/** @type {toa.samples.replay.replay} */
|
|
7
|
-
const replay = async (suite, paths) => {
|
|
7
|
+
const replay = async (suite, paths, options) => {
|
|
8
8
|
await stage.composition(paths)
|
|
9
9
|
|
|
10
|
-
const ok = await test(suite)
|
|
10
|
+
const ok = await test(suite, options)
|
|
11
11
|
|
|
12
12
|
await stage.shutdown()
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ it('should be', () => {
|
|
|
18
18
|
const paths = [generate()]
|
|
19
19
|
|
|
20
20
|
/** @type {toa.samples.suite.Options} */
|
|
21
|
-
const options = { component: generate() }
|
|
21
|
+
const options = { component: generate(), runner: { [generate()]: generate() } }
|
|
22
22
|
|
|
23
23
|
/** @type {boolean} */
|
|
24
24
|
let result
|
|
@@ -34,7 +34,7 @@ it('should load suite', async () => {
|
|
|
34
34
|
it('should replay suite', async () => {
|
|
35
35
|
const suite = await mock.suite.components.mock.results[0].value
|
|
36
36
|
|
|
37
|
-
expect(mock.replay.replay).toHaveBeenCalledWith(suite, paths)
|
|
37
|
+
expect(mock.replay.replay).toHaveBeenCalledWith(suite, paths, options.runner)
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
it('should return result', async () => {
|
|
@@ -27,7 +27,7 @@ const COMPONENTS = resolve(CONTEXT, 'components/*')
|
|
|
27
27
|
let paths
|
|
28
28
|
|
|
29
29
|
/** @type {toa.samples.suite.Options} */
|
|
30
|
-
const options = { component: generate() }
|
|
30
|
+
const options = { component: generate(), runner: { [generate()]: generate() } }
|
|
31
31
|
|
|
32
32
|
/** @type {boolean} */
|
|
33
33
|
let ok
|
|
@@ -55,7 +55,7 @@ it('should load integration suite', async () => {
|
|
|
55
55
|
it('should replay integration suite', async () => {
|
|
56
56
|
const suite = await mock.suite.context.mock.results[0].value
|
|
57
57
|
|
|
58
|
-
expect(replay.replay).toHaveBeenCalledWith(suite, paths)
|
|
58
|
+
expect(replay.replay).toHaveBeenCalledWith(suite, paths, options.runner)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('should return false if components replay failed', async () => {
|
|
@@ -75,7 +75,6 @@ it('should invoke operations with translated samples', async () => {
|
|
|
75
75
|
it('should emit translated messages', async () => {
|
|
76
76
|
/**
|
|
77
77
|
* @param {toa.samples.Message} declaration
|
|
78
|
-
* @param {string} id
|
|
79
78
|
* @returns {{index: number, message: toa.sampling.Message}}
|
|
80
79
|
*/
|
|
81
80
|
const translation = (declaration) => {
|
|
@@ -2,9 +2,9 @@ import * as _suite from './suite'
|
|
|
2
2
|
|
|
3
3
|
declare namespace toa.samples.replay {
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type components = (paths: string[], options?: _suite.Options) => Promise<boolean>
|
|
6
|
+
type context = (path: string, options?: _suite.Options) => Promise<boolean>
|
|
7
|
+
type replay = (suite: _suite.Suite, paths: string[], options?: object) => Promise<boolean>
|
|
8
8
|
|
|
9
9
|
}
|
|
10
10
|
|
package/samples/types/suite.d.ts
CHANGED
|
@@ -3,24 +3,25 @@ import * as _messages from './message'
|
|
|
3
3
|
|
|
4
4
|
declare namespace toa.samples {
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
namespace suite {
|
|
7
|
+
type Operations = Record<string, _operations.Set>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
type Options = {
|
|
10
|
+
id?: string
|
|
11
|
+
integration?: boolean
|
|
12
|
+
component?: string
|
|
13
|
+
operation?: string
|
|
14
|
+
title?: string
|
|
15
|
+
runner?: object
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
|
-
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
type Suite = {
|
|
20
|
+
title: string
|
|
21
|
+
autonomous: boolean
|
|
22
|
+
operations?: suite.Operations
|
|
23
|
+
messages?: _messages.Set
|
|
24
|
+
}
|
|
24
25
|
|
|
25
26
|
}
|
|
26
27
|
|