@toa.io/boot 1.0.0-alpha.313 → 1.0.0-alpha.314

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,21 @@
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.314](https://github.com/toa-io/toa/compare/v1.0.0-alpha.313...v1.0.0-alpha.314) (2026-09-19)
7
+
8
+ * feat(core)!: let an operation state how long its calls are remembered ([af177c2](https://github.com/toa-io/toa/commit/af177c2ab3d00d475840b5ef9e612f04e82b72bd))
9
+
10
+ ### Features
11
+
12
+ * **core:** a destination renders the component's events ([2f93b28](https://github.com/toa-io/toa/commit/2f93b28bed61a0afe99cb8cfa646ed7815467497))
13
+ * **core:** a reference may name a declaration its package claims ([8040f60](https://github.com/toa-io/toa/commit/8040f60976549ab90497675bb54e664261f5b6bb))
14
+
15
+ ### BREAKING CHANGES
16
+
17
+ * `inbox.retention` under 600 is refused. See
18
+ migrations/313.md.
19
+
20
+
6
21
  # [1.0.0-alpha.313](https://github.com/toa-io/toa/compare/v1.0.0-alpha.312...v1.0.0-alpha.313) (2026-09-18)
7
22
 
8
23
  **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.313",
3
+ "version": "1.0.0-alpha.314",
4
4
  "type": "module",
5
5
  "description": "Toa Boot",
6
6
  "author": "temich <tema.gurtovoy@gmail.com>",
@@ -21,15 +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.312",
25
- "@toa.io/core": "1.0.0-alpha.312",
26
- "@toa.io/definitions": "1.0.0-alpha.313",
24
+ "@toa.io/atomicity": "1.0.0-alpha.314",
25
+ "@toa.io/core": "1.0.0-alpha.314",
26
+ "@toa.io/definitions": "1.0.0-alpha.314",
27
27
  "@toa.io/generic": "1.0.0-alpha.311",
28
- "@toa.io/norm": "1.0.0-alpha.313",
28
+ "@toa.io/norm": "1.0.0-alpha.314",
29
29
  "@toa.io/schemas": "1.0.0-alpha.311",
30
30
  "clone-deep": "4.0.1",
31
31
  "dotenv": "17.4.2",
32
32
  "openspan": "1.0.0-alpha.305"
33
33
  },
34
- "gitHead": "7da3b2627ceeefd1fa19d5c8851be88d928523b6"
34
+ "gitHead": "4b7c0f4468e6fa89f95a69f43fed85c648fb033d"
35
35
  }
package/src/component.js CHANGED
@@ -34,6 +34,10 @@ const create = async (manifest, locator) => {
34
34
  )
35
35
  const context = await boot.context(manifest)
36
36
  const emission = await boot.emission(events, locator, context)
37
+
38
+ // a destination that renders the component's events renders them with its context
39
+ await boot.rendering(manifest, destinations, context)
40
+
37
41
  const outbox = boot.outbox(manifest, storage, emission, destinations)
38
42
 
39
43
  let state
@@ -20,12 +20,12 @@ const loading = {}
20
20
  * @returns {Promise<import('@toa.io/core/types').extensions.Factory>}
21
21
  */
22
22
  export const resolve = async (reference, base = process.cwd()) => {
23
- const path = find(reference, base)
23
+ const path = find(pack(reference), base)
24
24
 
25
25
  loading[path] ??= create(path)
26
26
  instances[path] = await loading[path]
27
27
 
28
- return instances[path]
28
+ return keyed(instances[path], reference)
29
29
  }
30
30
 
31
31
  /**
@@ -38,13 +38,37 @@ export const resolve = async (reference, base = process.cwd()) => {
38
38
  * @returns {import('@toa.io/core/types').extensions.Factory}
39
39
  */
40
40
  export const instance = (reference, base = process.cwd()) => {
41
- const factory = instances[find(reference, base)]
41
+ const factory = instances[find(pack(reference), base)]
42
42
 
43
43
  if (factory === undefined) throw new Error(`Extension '${reference}' is not loaded`)
44
44
 
45
- return factory
45
+ return keyed(factory, reference)
46
46
  }
47
47
 
48
+ /**
49
+ * `package#key` is a declaration a package claims beside its main one, and what the package's
50
+ * factory offers for that key answers for it — so a key is never taken for the package itself.
51
+ *
52
+ * @param {import('@toa.io/core/types').extensions.Factory} factory
53
+ * @param {string} reference
54
+ * @returns {import('@toa.io/core/types').extensions.Factory}
55
+ */
56
+ const keyed = (factory, reference) => {
57
+ const key = reference.split('#')[1]
58
+
59
+ if (key === undefined) return factory
60
+
61
+ const claimed = factory.keys?.[key]
62
+
63
+ if (claimed === undefined)
64
+ throw new Error(`'${reference}' names a key its package does not claim`)
65
+
66
+ return claimed
67
+ }
68
+
69
+ /** The package a reference is of. */
70
+ const pack = (reference) => reference.split('#')[0]
71
+
48
72
  const create = async (path) => {
49
73
  const { Factory } = await import(pathToFileURL(require.resolve(path)).href)
50
74
 
package/src/inbox.js CHANGED
@@ -7,4 +7,6 @@
7
7
  * @returns {boolean}
8
8
  */
9
9
  export const inbox = (manifest) =>
10
- Object.values(manifest.operations ?? {}).some((definition) => definition.once === true)
10
+ Object.values(manifest.operations ?? {}).some(
11
+ (definition) => definition.once === true || typeof definition.once === 'number'
12
+ )
package/src/index.js CHANGED
@@ -22,6 +22,7 @@ export { manifest } from './manifest.js'
22
22
  export { operation } from './operation.js'
23
23
  export { receivers, receive } from './receivers.js'
24
24
  export { remote } from './remote.js'
25
+ export { rendering } from './rendering.js'
25
26
  export { storage } from './storage.js'
26
27
  export { guards } from './guards.js'
27
28
  export { host } from './host.js'
@@ -0,0 +1,50 @@
1
+ import { Event, Rendering } from '@toa.io/core'
2
+
3
+ import * as boot from './index.js'
4
+
5
+ /**
6
+ * Gives every destination that names the events it renders a `Rendering` of them, made with the
7
+ * component's own bridges. Every event of the manifest may be named, including those nothing
8
+ * consumes and are therefore not published: a destination writes somewhere of its own.
9
+ *
10
+ * @param {toa.norm.Component} manifest
11
+ * @param {import('@toa.io/core/types').outbox.Destination[]} destinations
12
+ * @param {import('@toa.io/core').Context} context
13
+ * @returns {Promise<void>}
14
+ */
15
+ export const rendering = async (manifest, destinations, context) => {
16
+ for (const destination of destinations) {
17
+ if (destination.renders === undefined) continue
18
+
19
+ const events = new Map()
20
+
21
+ for (const label of destination.renders) {
22
+ const definition = manifest.events?.[label]
23
+
24
+ if (definition === undefined)
25
+ throw new Error(
26
+ `Component '${manifest.locator.id}' has no event '${label}' to render for ` +
27
+ `'${destination.name}'`
28
+ )
29
+
30
+ const bridge = await boot.bridge.event(
31
+ definition.bridge,
32
+ definition.path,
33
+ label,
34
+ context
35
+ )
36
+ const event = new Event(
37
+ { ...definition, label: `${manifest.locator.id}.${label}` },
38
+ null,
39
+ bridge
40
+ )
41
+
42
+ events.set(label, event)
43
+ }
44
+
45
+ const rendering = new Rendering(events)
46
+
47
+ destination.rendering = rendering
48
+ destination.depends(rendering)
49
+ }
50
+ }