@toa.io/userland 1.0.0-alpha.33 → 1.0.0-alpha.331

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +358 -0
  2. package/example/components/echo/manifest.toa.yaml +15 -5
  3. package/example/components/echo/operations/get.js +1 -5
  4. package/example/components/echo/operations/resolve.js +1 -5
  5. package/example/components/echo/operations/signal.js +3 -7
  6. package/example/components/math.calculations/manifest.toa.yaml +19 -6
  7. package/example/components/math.calculations/operations/add.js +1 -5
  8. package/example/components/math.calculations/operations/increment.js +1 -5
  9. package/example/components/math.proxy/manifest.toa.yaml +8 -3
  10. package/example/components/math.proxy/operations/add.js +1 -5
  11. package/example/components/tea.pots/manifest.toa.yaml +29 -9
  12. package/example/components/tea.pots/operations/same.js +1 -5
  13. package/example/components/tea.pots/receivers/store.orders.created.js +1 -5
  14. package/example/components/web/manifest.toa.yaml +2 -4
  15. package/example/components/web/operations/get.js +3 -8
  16. package/example/context.toa.yaml +2 -7
  17. package/example/stage/call.test.js +17 -10
  18. package/example/stage/events.test.js +63 -16
  19. package/example/stage/invoke.test.js +12 -9
  20. package/package.json +19 -13
  21. package/readme.md +58 -1
  22. package/stage/package.json +1 -0
  23. package/stage/src/component.js +3 -7
  24. package/stage/src/composition.js +3 -7
  25. package/stage/src/index.js +9 -16
  26. package/stage/src/manifest.js +2 -6
  27. package/stage/src/map.js +15 -0
  28. package/stage/src/quiescence.js +16 -0
  29. package/stage/src/remote.js +11 -8
  30. package/stage/src/service.js +11 -10
  31. package/stage/src/shutdown.js +16 -6
  32. package/stage/src/state.js +2 -4
  33. package/stage/src/workload.js +53 -0
  34. package/stage/test/boot.mock.js +10 -11
  35. package/stage/test/component.test.js +20 -10
  36. package/stage/test/composition.test.js +11 -9
  37. package/stage/test/manifest.test.js +15 -8
  38. package/stage/test/remote.test.js +14 -12
  39. package/stage/test/shutdown.test.js +28 -15
  40. package/stage/test/state.mock.js +5 -6
  41. package/stage/test/state.test.js +13 -12
  42. package/stage/types/index.d.ts +21 -8
  43. package/stage/types/state.d.ts +3 -4
  44. package/template/_gitignore +3 -0
  45. package/template/components/hello/manifest.toa.yaml +22 -0
  46. package/template/components/hello/operations/greet.ts +5 -0
  47. package/template/components/notes/manifest.toa.yaml +25 -0
  48. package/template/context.toa.yaml +29 -0
  49. package/template/cucumber.js +4 -0
  50. package/template/docker-compose.yaml +62 -0
  51. package/template/ecosystem.config.js +29 -0
  52. package/template/features/hello.feature +14 -0
  53. package/template/features/notes.feature +29 -0
  54. package/template/features/steps/application.ts +22 -0
  55. package/template/features/steps/http.ts +19 -0
  56. package/template/package.json +28 -0
  57. package/template/tsconfig.json +15 -0
@@ -1,27 +1,29 @@
1
- 'use strict'
1
+ import { it, mock as mocking } from 'node:test'
2
+ import assert from 'node:assert/strict'
2
3
 
3
- const { generate } = require('randomstring')
4
+ import { generate } from 'randomstring'
5
+ import * as _boot from './boot.mock.js'
4
6
 
5
7
  const mock = {
6
- boot: require('./boot.mock')
8
+ boot: _boot
7
9
  }
8
10
 
9
- jest.mock('@toa.io/boot', () => mock.boot)
11
+ mocking.module('@toa.io/boot', { namedExports: mock.boot })
10
12
 
11
- const stage = require('../')
13
+ const stage = await import('../src/index.js')
12
14
 
13
15
  const paths = [generate(), generate()]
14
16
 
15
17
  it('should be', () => {
16
- expect(stage.composition).toBeDefined()
18
+ assert.notStrictEqual(stage.composition, undefined)
17
19
  })
18
20
 
19
21
  it('should boot composition', async () => {
20
22
  await stage.composition(paths)
21
23
 
22
- expect(mock.boot.composition.mock.calls[0][0]).toStrictEqual(paths)
24
+ assert.deepStrictEqual(mock.boot.composition.mock.calls[0].arguments[0], paths)
23
25
 
24
- const composition = await mock.boot.composition.mock.results[0].value
26
+ const composition = await mock.boot.composition.mock.calls[0].result
25
27
 
26
- expect(composition.connect).toHaveBeenCalled()
28
+ assert.ok(composition.connect.mock.callCount() > 0)
27
29
  })
@@ -1,17 +1,20 @@
1
- 'use strict'
1
+ import { it, mock as mocking } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { isDeepStrictEqual } from 'node:util'
2
4
 
3
- const { generate } = require('randomstring')
5
+ import { generate } from 'randomstring'
6
+ import * as _boot from './boot.mock.js'
4
7
 
5
8
  const mock = {
6
- boot: require('./boot.mock')
9
+ boot: _boot
7
10
  }
8
11
 
9
- jest.mock('@toa.io/boot', () => mock.boot)
12
+ mocking.module('@toa.io/boot', { namedExports: mock.boot })
10
13
 
11
- const stage = require('../')
14
+ const stage = await import('../src/index.js')
12
15
 
13
16
  it('should be', () => {
14
- expect(stage.manifest).toBeDefined()
17
+ assert.notStrictEqual(stage.manifest, undefined)
15
18
  })
16
19
 
17
20
  it('should boot manifest', async () => {
@@ -19,6 +22,10 @@ it('should boot manifest', async () => {
19
22
 
20
23
  const manifest = await stage.manifest(path)
21
24
 
22
- expect(mock.boot.manifest).toHaveBeenCalledWith(path)
23
- expect(manifest).toStrictEqual(await mock.boot.manifest.mock.results[0].value)
25
+ assert.ok(
26
+ mock.boot.manifest.mock.calls.some(
27
+ (call) => call.arguments.length === 1 && isDeepStrictEqual(call.arguments[0], path)
28
+ )
29
+ )
30
+ assert.deepStrictEqual(manifest, await mock.boot.manifest.mock.calls[0].result)
24
31
  })
@@ -1,17 +1,19 @@
1
- 'use strict'
1
+ import { it, mock as mocking } from 'node:test'
2
+ import assert from 'node:assert/strict'
2
3
 
3
- const { generate } = require('randomstring')
4
+ import { generate } from 'randomstring'
5
+ import * as _boot from './boot.mock.js'
4
6
 
5
7
  const mock = {
6
- boot: require('./boot.mock')
8
+ boot: _boot
7
9
  }
8
10
 
9
- jest.mock('@toa.io/boot', () => mock.boot)
11
+ mocking.module('@toa.io/boot', { namedExports: mock.boot })
10
12
 
11
- const stage = require('../')
13
+ const stage = await import('../src/index.js')
12
14
 
13
15
  it('should be', () => {
14
- expect(stage.remote).toBeDefined()
16
+ assert.notStrictEqual(stage.remote, undefined)
15
17
  })
16
18
 
17
19
  it('should connect remote', async () => {
@@ -21,12 +23,12 @@ it('should connect remote', async () => {
21
23
 
22
24
  const remote = await stage.remote(id)
23
25
 
24
- expect(mock.boot.remote).toHaveBeenCalled()
25
- expect(remote).toStrictEqual(await mock.boot.remote.mock.results[0].value)
26
- expect(remote.connect).toHaveBeenCalled()
26
+ assert.ok(mock.boot.remote.mock.callCount() > 0)
27
+ assert.deepStrictEqual(remote, await mock.boot.remote.mock.calls[0].result)
28
+ assert.ok(remote.connect.mock.callCount() > 0)
27
29
 
28
- const locator = mock.boot.remote.mock.calls[0][0]
30
+ const locator = mock.boot.remote.mock.calls[0].arguments[0]
29
31
 
30
- expect(locator).toBeDefined()
31
- expect(locator).toMatchObject({ name, namespace })
32
+ assert.notStrictEqual(locator, undefined)
33
+ assert.partialDeepStrictEqual(locator, { name, namespace })
32
34
  })
@@ -1,24 +1,27 @@
1
- 'use strict'
1
+ import { it, beforeEach, mock as mocking } from 'node:test'
2
+ import assert from 'node:assert/strict'
2
3
 
3
- const { generate } = require('randomstring')
4
+ import { generate } from 'randomstring'
5
+ import * as _boot from './boot.mock.js'
6
+ import * as _state from './state.mock.js'
4
7
 
5
8
  const mock = {
6
- boot: require('./boot.mock'),
7
- state: require('./state.mock')
9
+ boot: _boot,
10
+ state: _state
8
11
  }
9
12
 
10
- jest.mock('@toa.io/boot', () => mock.boot)
11
- jest.mock('../src/state', () => mock.state)
13
+ mocking.module('@toa.io/boot', { namedExports: mock.boot })
14
+ mocking.module('../src/state', { namedExports: mock.state })
12
15
 
13
- const { state } = require('../src/state')
14
- const stage = require('../')
16
+ const { state } = await import('../src/state.js')
17
+ const stage = await import('../src/index.js')
15
18
 
16
19
  beforeEach(() => {
17
- jest.clearAllMocks()
20
+ resetCalls()
18
21
  })
19
22
 
20
23
  it('should be', () => {
21
- expect(stage.shutdown).toBeDefined()
24
+ assert.notStrictEqual(stage.shutdown, undefined)
22
25
  })
23
26
 
24
27
  it('should disconnect components', async () => {
@@ -27,7 +30,7 @@ it('should disconnect components', async () => {
27
30
 
28
31
  await stage.shutdown()
29
32
 
30
- expect(component.disconnect).toHaveBeenCalled()
33
+ assert.ok(component.disconnect.mock.callCount() > 0)
31
34
  })
32
35
 
33
36
  it('should disconnect compositions', async () => {
@@ -36,9 +39,9 @@ it('should disconnect compositions', async () => {
36
39
  await stage.composition(paths)
37
40
  await stage.shutdown()
38
41
 
39
- const composition = await mock.boot.composition.mock.results[0].value
42
+ const composition = await mock.boot.composition.mock.calls[0].result
40
43
 
41
- expect(composition.disconnect).toHaveBeenCalled()
44
+ assert.ok(composition.disconnect.mock.callCount() > 0)
42
45
  })
43
46
 
44
47
  it('should disconnect remotes', async () => {
@@ -47,11 +50,21 @@ it('should disconnect remotes', async () => {
47
50
  const remote = await stage.remote(id)
48
51
  await stage.shutdown()
49
52
 
50
- expect(remote.disconnect).toHaveBeenCalled()
53
+ assert.ok(remote.disconnect.mock.callCount() > 0)
51
54
  })
52
55
 
53
56
  it('should reset state', async () => {
54
57
  await stage.shutdown()
55
58
 
56
- expect(state.reset).toHaveBeenCalled()
59
+ assert.ok(state.reset.mock.callCount() > 0)
57
60
  })
61
+
62
+ function resetCalls(target = [assert, mock, stage], seen = new Set()) {
63
+ if (target === null || typeof target !== 'object' || seen.has(target)) return
64
+
65
+ seen.add(target)
66
+
67
+ for (const value of Object.values(target))
68
+ if (typeof value === 'function' && value.mock !== undefined) value.mock.resetCalls()
69
+ else resetCalls(value, seen)
70
+ }
@@ -1,8 +1,7 @@
1
- 'use strict'
1
+ import { mock } from 'node:test'
2
2
 
3
- const original = jest.requireActual('../src/state')
3
+ // this module defines the replacement, so it still sees the real one
4
+ import * as original from '../src/state.js'
4
5
 
5
- const reset = jest.fn(() => original.state.reset())
6
- const state = { ...original.state, reset }
7
-
8
- module.exports = { state }
6
+ const reset = mock.fn(() => original.state.reset())
7
+ export const state = { ...original.state, reset }
@@ -1,19 +1,20 @@
1
- 'use strict'
1
+ import { it } from 'node:test'
2
+ import assert from 'node:assert/strict'
2
3
 
3
- const { state } = require('../src/state')
4
+ import { state } from '../src/state.js'
4
5
 
5
6
  it('should be', () => {
6
- expect(state).toBeDefined()
7
+ assert.notStrictEqual(state, undefined)
7
8
  })
8
9
 
9
10
  it('should reset', () => {
10
- const component = /** @type {toa.core.Component} */ 1
11
- const composition = /** @type {toa.core.Connector} */ 2
12
- const remote = /** @type {toa.core.Component} */ 3
11
+ const component = /** @type {import('@toa.io/core').Component} */ 1
12
+ const composition = /** @type {import('@toa.io/core').Connector} */ 2
13
+ const remote = /** @type {import('@toa.io/core').Component} */ 3
13
14
 
14
- expect(state.components.length).toStrictEqual(0)
15
- expect(state.compositions.length).toStrictEqual(0)
16
- expect(state.remotes.length).toStrictEqual(0)
15
+ assert.deepStrictEqual(state.components.length, 0)
16
+ assert.deepStrictEqual(state.compositions.length, 0)
17
+ assert.deepStrictEqual(state.remotes.length, 0)
17
18
 
18
19
  state.components.push(component)
19
20
  state.compositions.push(composition)
@@ -21,7 +22,7 @@ it('should reset', () => {
21
22
 
22
23
  state.reset()
23
24
 
24
- expect(state.components.length).toStrictEqual(0)
25
- expect(state.compositions.length).toStrictEqual(0)
26
- expect(state.remotes.length).toStrictEqual(0)
25
+ assert.deepStrictEqual(state.components.length, 0)
26
+ assert.deepStrictEqual(state.compositions.length, 0)
27
+ assert.deepStrictEqual(state.remotes.length, 0)
27
28
  })
@@ -1,17 +1,30 @@
1
- import * as _core from '@toa.io/core'
1
+ import type * as _core from '@toa.io/core'
2
2
  import * as _norm from '@toa.io/norm/types'
3
3
  import * as _composition from '@toa.io/boot/types/composition'
4
+ import type * as _boot from '@toa.io/boot'
4
5
 
5
- export function manifest (path: string): Promise<_norm.Component>
6
+ export function manifest(path: string): Promise<_norm.Component>
6
7
 
7
- export function component (path: string): Promise<_core.Component>
8
+ /** what this process is given about the components it calls */
9
+ export function map(contracts: Record<string, _norm.Contract> | undefined): void
8
10
 
9
- export function composition (paths: string[], options?: _composition.Options): Promise<void>
11
+ export function component(path: string): Promise<_core.Component>
10
12
 
11
- export function compose (paths: string[]): Promise<void>
13
+ export function composition(
14
+ paths: string[],
15
+ options?: _composition.Options
16
+ ): Promise<void>
12
17
 
13
- export function serve (ref: string): Promise<_core.Component>
18
+ export function compose(paths: string[]): Promise<void>
14
19
 
15
- export function remote (id: string): Promise<_core.Component>
20
+ /** the same components as a process runs them: behind a gate, with the residents beside */
21
+ export function workload(
22
+ paths: string[],
23
+ options?: _composition.Options
24
+ ): Promise<_boot.Workload>
16
25
 
17
- export function shutdown (): Promise<void>
26
+ export function serve(ref: string): Promise<_core.Component>
27
+
28
+ export function remote(id: string): Promise<_core.Component>
29
+
30
+ export function shutdown(): Promise<void>
@@ -1,15 +1,14 @@
1
- import * as _core from '@toa.io/core'
2
-
3
- declare namespace toa.stage{
1
+ import type * as _core from '@toa.io/core'
4
2
 
3
+ declare namespace toa.stage {
5
4
  type State = {
6
5
  reset: () => void
7
6
  components: _core.Component[]
8
7
  compositions: _core.Connector[]
8
+ workloads: _core.Connector[]
9
9
  services: _core.Connector[]
10
10
  remotes: _core.Component[]
11
11
  }
12
-
13
12
  }
14
13
 
15
14
  export type State = toa.stage.State
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ .env*
3
+ .map.json
@@ -0,0 +1,22 @@
1
+ name: hello
2
+
3
+ operations:
4
+ greet:
5
+ input:
6
+ type: object
7
+ properties:
8
+ name: { type: string, maxLength: 64 }
9
+ output:
10
+ type: object
11
+ properties:
12
+ greeting: { type: string }
13
+ required: [greeting]
14
+
15
+ exposition:
16
+ /:
17
+ anonymous: true
18
+ io:output: true
19
+ GET:
20
+ endpoint: greet
21
+ query:
22
+ parameters: [name]
@@ -0,0 +1,5 @@
1
+ import type { GreetInput } from '../types/index.d.ts'
2
+
3
+ export async function computation(input: GreetInput) {
4
+ return { greeting: `Hello, ${input.name ?? 'world'}!` }
5
+ }
@@ -0,0 +1,25 @@
1
+ name: notes
2
+
3
+ entity:
4
+ properties:
5
+ text: { type: string, maxLength: 1024 }
6
+ required: [text]
7
+
8
+ operations:
9
+ create:
10
+ forward: transit
11
+ query: false
12
+ input:
13
+ type: object
14
+ properties:
15
+ text: { type: string, maxLength: 1024 }
16
+ required: [text]
17
+
18
+ exposition:
19
+ /:
20
+ anonymous: true
21
+ io:output: [id, text]
22
+ GET: enumerate
23
+ POST: create
24
+ /:id:
25
+ GET: observe
@@ -0,0 +1,29 @@
1
+ name: {{name}}
2
+ registry: registry.example.com/{{name}}
3
+
4
+ amqp: amqp://localhost
5
+ mongodb: mongodb://localhost
6
+ stash: redis://localhost
7
+
8
+ atomicity:
9
+ redis: redis://localhost
10
+
11
+ storages:
12
+ tmp:
13
+ provider: tmp
14
+ directory: {{name}}
15
+
16
+ exposition:
17
+ authorities:
18
+ local: localhost:8000
19
+
20
+ configuration:
21
+ identity.tokens:
22
+ keys:
23
+ - id: key0
24
+ key: $IDENTITY_TOKENS_ENCRYPTION_KEY0
25
+
26
+ ingress:
27
+ hosts: [localhost]
28
+
29
+ resources: ~
@@ -0,0 +1,4 @@
1
+ export default {
2
+ import: ['features/steps/*.ts'],
3
+ failFast: true
4
+ }
@@ -0,0 +1,62 @@
1
+ # What a local run connects to. `developer` and `secret` are what `toa env --dev` writes.
2
+ name: {{name}}
3
+ volumes:
4
+ mongo-data:
5
+ mongo-key:
6
+ services:
7
+ rabbitmq:
8
+ image: rabbitmq:4.2.4-management
9
+ ports:
10
+ - "5672:5672"
11
+ - "15672:15672"
12
+ environment:
13
+ RABBITMQ_DEFAULT_USER: developer
14
+ RABBITMQ_DEFAULT_PASS: secret
15
+ healthcheck:
16
+ test: rabbitmq-diagnostics -q ping
17
+ interval: 5s
18
+ timeout: 5s
19
+ retries: 30
20
+
21
+ # a replica set of one member: transactions and change streams need one
22
+ mongodb:
23
+ image: mongo:8.0.16
24
+ ports:
25
+ - "27017:27017"
26
+ environment:
27
+ MONGO_INITDB_ROOT_USERNAME: developer
28
+ MONGO_INITDB_ROOT_PASSWORD: secret
29
+ volumes:
30
+ - mongo-data:/data/db
31
+ - mongo-key:/etc/mongo-keyfile
32
+ entrypoint: >
33
+ bash -c '
34
+ set -e
35
+
36
+ if [ ! -f /etc/mongo-keyfile/keyfile ]; then
37
+ umask 077
38
+ openssl rand -base64 756 > /etc/mongo-keyfile/keyfile
39
+ chown mongodb:mongodb /etc/mongo-keyfile/keyfile
40
+ fi
41
+
42
+ exec docker-entrypoint.sh mongod --replSet rs0 --bind_ip_all --keyFile /etc/mongo-keyfile/keyfile
43
+ '
44
+ healthcheck:
45
+ test: >
46
+ mongosh "mongodb://developer:secret@localhost:27017/admin?directConnection=true" --quiet --eval '
47
+ try { rs.status() } catch (e) { rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] }) }
48
+ if (!db.hello().isWritablePrimary) quit(1)
49
+ '
50
+ interval: 5s
51
+ timeout: 5s
52
+ retries: 30
53
+
54
+ redis:
55
+ image: redis:8.6.1
56
+ ports:
57
+ - "6379:6379"
58
+ healthcheck:
59
+ test: redis-cli ping
60
+ interval: 5s
61
+ timeout: 5s
62
+ retries: 30
@@ -0,0 +1,29 @@
1
+ import { readdirSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ // the binary of this project's Toa, by its path: pm2 resolves a script through the PATH of the
5
+ // shell that starts it, which has `node_modules/.bin` only under `npm run`
6
+ const toa = join(import.meta.dirname, 'node_modules/.bin/toa')
7
+
8
+ const components = readdirSync(join(import.meta.dirname, 'components'), {
9
+ withFileTypes: true
10
+ })
11
+ .filter((entry) => entry.isDirectory())
12
+ .map((entry) => join('components', entry.name))
13
+
14
+ const common = {
15
+ script: toa,
16
+ cwd: import.meta.dirname,
17
+ autorestart: false,
18
+ watch: false,
19
+ merge_logs: true,
20
+ wait_ready: true,
21
+ listen_timeout: 60_000
22
+ }
23
+
24
+ export const apps = [
25
+ // what Toa serves beside an application: its gateway, configuration and introspection
26
+ { ...common, name: 'sys', args: 'serve configuration exposition introspection' },
27
+ // the application's components
28
+ { ...common, name: 'app', args: `compose ${components.join(' ')}` }
29
+ ]
@@ -0,0 +1,14 @@
1
+ Feature: Hello
2
+
3
+ Scenario: Greeting by name
4
+ When the request is sent:
5
+ """
6
+ GET /hello/?name=Toa HTTP/1.1
7
+ accept: application/yaml
8
+ """
9
+ Then the response is received:
10
+ """
11
+ 200 OK
12
+
13
+ greeting: Hello, Toa!
14
+ """
@@ -0,0 +1,29 @@
1
+ Feature: Notes
2
+
3
+ Scenario: Keeping a note
4
+ When the request is sent:
5
+ """
6
+ POST /notes/ HTTP/1.1
7
+ content-type: application/yaml
8
+ accept: application/yaml
9
+
10
+ text: Buy milk
11
+ """
12
+ Then the response is received:
13
+ """
14
+ 201 Created
15
+
16
+ id: ${{ id }}
17
+ text: Buy milk
18
+ """
19
+ When the request is sent:
20
+ """
21
+ GET /notes/${{ id }}/ HTTP/1.1
22
+ accept: application/yaml
23
+ """
24
+ Then the response is received:
25
+ """
26
+ 200 OK
27
+
28
+ text: Buy milk
29
+ """
@@ -0,0 +1,22 @@
1
+ import { readdir, readFile } from 'node:fs/promises'
2
+ import { resolve } from 'node:path'
3
+ import { BeforeAll, AfterAll } from '@cucumber/cucumber'
4
+ import * as stage from '@toa.io/userland/stage'
5
+
6
+ const root = resolve(import.meta.dirname, '../..')
7
+ const components = resolve(root, 'components')
8
+
9
+ BeforeAll({ timeout: 60_000 }, async function () {
10
+ const map = await readFile(resolve(root, '.map.json'), 'utf8')
11
+ const entries = await readdir(components)
12
+ const paths = entries.map((entry) => resolve(components, entry))
13
+
14
+ stage.map(JSON.parse(map))
15
+
16
+ // the components run in this process; what serves them is started with `npm run sys`
17
+ await stage.compose(paths)
18
+ })
19
+
20
+ AfterAll(async function () {
21
+ await stage.shutdown()
22
+ })
@@ -0,0 +1,19 @@
1
+ import { Before, When, Then } from '@cucumber/cucumber'
2
+ import { Agent } from '@toa.io/agent'
3
+
4
+ // what the steps of one scenario share
5
+ export interface World {
6
+ agent: Agent
7
+ }
8
+
9
+ Before(function (this: World) {
10
+ this.agent = new Agent('http://localhost:8000')
11
+ })
12
+
13
+ When('the request is sent:', async function (this: World, text: string) {
14
+ await this.agent.request(text)
15
+ })
16
+
17
+ Then('the response is received:', function (this: World, text: string) {
18
+ this.agent.responseIncludes(text)
19
+ })
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "postinstall": "toa npm",
7
+ "dock": "docker compose up -d --wait",
8
+ "env": "toa types --quiet && toa env --dev && toa map",
9
+ "start": "pm2 start ecosystem.config.js",
10
+ "restart": "npm run env && pm2 restart ecosystem.config.js",
11
+ "stop": "pm2 delete ecosystem.config.js",
12
+ "sys": "pm2 start ecosystem.config.js --only sys",
13
+ "features": "cucumber-js",
14
+ "typecheck": "tsc"
15
+ },
16
+ "workspaces": [
17
+ "components/*"
18
+ ],
19
+ "devDependencies": {
20
+ "@cucumber/cucumber": "13.2.1",
21
+ "@toa.io/agent": "{{agent}}",
22
+ "@toa.io/operations": "{{version}}",
23
+ "@toa.io/runtime": "{{version}}",
24
+ "@toa.io/userland": "{{version}}",
25
+ "@types/node": "26.6.4",
26
+ "typescript": "7.0.2"
27
+ }
28
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "nodenext",
4
+ "moduleResolution": "nodenext",
5
+ "target": "esnext",
6
+ "types": ["node"],
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "skipLibCheck": true,
10
+ "allowImportingTsExtensions": true,
11
+ "verbatimModuleSyntax": true,
12
+ "erasableSyntaxOnly": true
13
+ },
14
+ "include": ["components", "features"]
15
+ }