@toa.io/boot 1.0.0-alpha.291 → 1.0.0-alpha.293

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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.293](https://github.com/toa-io/toa/compare/v1.0.0-alpha.292...v1.0.0-alpha.293) (2026-09-07)
7
+
8
+ **Note:** Version bump only for package @toa.io/boot
9
+
10
+
11
+
12
+
13
+
14
+ # [1.0.0-alpha.292](https://github.com/toa-io/toa/compare/v1.0.0-alpha.291...v1.0.0-alpha.292) (2026-09-07)
15
+
16
+ ### Features
17
+
18
+ * **definitions:** the version of Toa is the definitions package's ([3d0272e](https://github.com/toa-io/toa/commit/3d0272ea0ab862f4b6c2e58a2f003f92d0f8a87f))
19
+ * **definitions:** what a package declares is read from one package ([7052341](https://github.com/toa-io/toa/commit/70523411b5d9e2b204c999aa02365173f3bb518d))
20
+ * **norm:** a package's definition is read by one resolver ([bffd41c](https://github.com/toa-io/toa/commit/bffd41c8d18c42786b0bf321623088b9dabc4724))
21
+
22
+
6
23
  # [1.0.0-alpha.291](https://github.com/toa-io/toa/compare/v1.0.0-alpha.290...v1.0.0-alpha.291) (2026-09-07)
7
24
 
8
25
  **Note:** Version bump only for package @toa.io/boot
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/boot",
3
- "version": "1.0.0-alpha.291",
3
+ "version": "1.0.0-alpha.293",
4
4
  "type": "module",
5
5
  "description": "Toa Boot",
6
6
  "author": "temich <tema.gurtovoy@gmail.com>",
@@ -21,14 +21,15 @@
21
21
  "test": "echo \"Error: run tests from root\" && exit 1"
22
22
  },
23
23
  "dependencies": {
24
- "@toa.io/atomicity": "1.0.0-alpha.291",
25
- "@toa.io/core": "1.0.0-alpha.291",
26
- "@toa.io/generic": "1.0.0-alpha.291",
27
- "@toa.io/norm": "1.0.0-alpha.291",
28
- "@toa.io/schemas": "1.0.0-alpha.291",
24
+ "@toa.io/atomicity": "1.0.0-alpha.293",
25
+ "@toa.io/core": "1.0.0-alpha.293",
26
+ "@toa.io/definitions": "1.0.0-alpha.293",
27
+ "@toa.io/generic": "1.0.0-alpha.292",
28
+ "@toa.io/norm": "1.0.0-alpha.293",
29
+ "@toa.io/schemas": "1.0.0-alpha.293",
29
30
  "clone-deep": "4.0.1",
30
31
  "dotenv": "17.4.2",
31
- "openspan": "1.0.0-alpha.286"
32
+ "openspan": "1.0.0-alpha.293"
32
33
  },
33
- "gitHead": "bcd8d8d07bd3e64fc826af8719472404662cc37f"
34
+ "gitHead": "1e05b3ab64758324c58c425f1f8e52e9f35f1da8"
34
35
  }
@@ -1,3 +1,4 @@
1
+ import { definition } from '@toa.io/norm'
1
2
  import { LOOP } from './constants.js'
2
3
  import { factory } from './factory.js'
3
4
 
@@ -8,7 +9,7 @@ export const produce = async (component, operations) => {
8
9
  for (const [binding, endpoints] of group(operations)) {
9
10
  const made = await factory(binding)
10
11
  const producer = made.producer(component.locator, endpoints, component)
11
- const { properties } = await import(binding)
12
+ const { properties } = (await definition(binding)).module
12
13
 
13
14
  if (properties.local === true) local.push(producer)
14
15
  else other.push(producer)
@@ -1,6 +1,6 @@
1
1
  import { console } from 'openspan'
2
2
  import { Composition } from '@toa.io/core'
3
- import { version } from '@toa.io/runtime'
3
+ import { version } from '@toa.io/definitions'
4
4
  import { environment } from '@toa.io/generic'
5
5
 
6
6
  import * as boot from './index.js'
package/src/manifest.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import clone from 'clone-deep'
2
- import { basename } from 'node:path'
2
+ import { existsSync } from 'node:fs'
3
+ import { readFile } from 'node:fs/promises'
4
+ import { basename, join } from 'node:path'
3
5
  import { merge } from '@toa.io/generic'
4
- import { component as load } from '@toa.io/norm'
6
+ import { component as load, revive, NORMALIZED } from '@toa.io/norm'
5
7
  import { Locator } from '@toa.io/core'
6
8
 
7
9
  import { span } from './span.js'
@@ -11,41 +13,9 @@ export const manifest = async (path, options = {}) => {
11
13
 
12
14
  const manifest = await span(
13
15
  { name: `manifest ${basename(path)}`, attributes: { path } },
14
- async () => await load(path)
16
+ async () => await read(path)
15
17
  )
16
18
 
17
- if (options?.bindings !== undefined) {
18
- if ('operations' in manifest) {
19
- for (const operation of Object.values(manifest.operations)) {
20
- operation.bindings = options.bindings
21
- }
22
- }
23
-
24
- let asyncBinding
25
-
26
- for (const binding of options.bindings) {
27
- const { properties } = await import(binding)
28
-
29
- if (properties?.async === true) {
30
- asyncBinding = binding
31
- break
32
- }
33
- }
34
-
35
- if (asyncBinding === undefined)
36
- throw new Error('Bindings override must contain at least one async binding')
37
-
38
- if ('events' in manifest) {
39
- for (const event of Object.values(manifest.events)) event.binding = asyncBinding
40
- }
41
-
42
- if ('receivers' in manifest) {
43
- for (const receiver of Object.values(manifest.receivers)) {
44
- if (receiver.source === undefined) receiver.binding = asyncBinding
45
- }
46
- }
47
- }
48
-
49
19
  if (manifest.extensions === undefined) manifest.extensions = {}
50
20
 
51
21
  if (options.extensions !== undefined) {
@@ -62,4 +32,18 @@ export const manifest = async (path, options = {}) => {
62
32
  return manifest
63
33
  }
64
34
 
35
+ /**
36
+ * What the build wrote, where it wrote one. An image carries the manifest a build normalised;
37
+ * a workspace has no such file and is read as it always was.
38
+ *
39
+ * @param {string} path
40
+ */
41
+ async function read(path) {
42
+ const file = join(path, NORMALIZED)
43
+
44
+ if (!existsSync(file)) return await load(path)
45
+
46
+ return revive(JSON.parse(await readFile(file, 'utf8')), path)
47
+ }
48
+
65
49
  const DEFAULTS = {}
@@ -1,9 +1,27 @@
1
1
  import { it, mock } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
 
4
+ import { mkdtemp, writeFile } from 'node:fs/promises'
5
+ import { join } from 'node:path'
6
+ import { tmpdir } from 'node:os'
4
7
  import { generate } from 'randomstring'
5
8
 
6
- mock.module('@toa.io/norm', { namedExports: { component: () => mockComponent() } })
9
+ const NORMALIZED = 'manifest.toa.json'
10
+
11
+ let normalised = 0
12
+
13
+ mock.module('@toa.io/norm', {
14
+ namedExports: {
15
+ component: () => {
16
+ normalised++
17
+
18
+ return mockComponent()
19
+ },
20
+ definition: async () => ({ module: {} }),
21
+ revive: (declared, path) => ({ ...declared, path }),
22
+ NORMALIZED
23
+ }
24
+ })
7
25
 
8
26
  const { manifest } = await import('./manifest.js')
9
27
 
@@ -17,6 +35,29 @@ it('should not modify options', async () => {
17
35
  assert.deepStrictEqual(options.extensions.length, 2)
18
36
  })
19
37
 
38
+ it('should normalize a component the build did not', async () => {
39
+ const before = normalised
40
+
41
+ await manifest(path)
42
+
43
+ assert.strictEqual(normalised, before + 1)
44
+ })
45
+
46
+ it('should read what the build wrote, and not normalize', async () => {
47
+ const root = await mkdtemp(join(tmpdir(), 'toa-manifest-test'))
48
+ const declared = { name: 'tasks', namespace: 'todos', operations: { compute: {} } }
49
+
50
+ await writeFile(join(root, NORMALIZED), JSON.stringify(declared))
51
+
52
+ const before = normalised
53
+ const read = await manifest(root)
54
+
55
+ assert.strictEqual(normalised, before, 'the component was normalized')
56
+ assert.strictEqual(read.path, root)
57
+ assert.deepStrictEqual(read.operations, declared.operations)
58
+ assert.strictEqual(read.locator.id, 'todos.tasks')
59
+ })
60
+
20
61
  function mockComponent() {
21
62
  return { name: generate(), namespace: generate() }
22
63
  }