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

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,15 @@
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.315](https://github.com/toa-io/toa/compare/v1.0.0-alpha.314...v1.0.0-alpha.315) (2026-09-23)
7
+
8
+ * feat(map)!: leave out of a contract what the runtime gives every component ([b81837a](https://github.com/toa-io/toa/commit/b81837a3bc4771d7ee1c10fe613c9a1d7501bf1a))
9
+
10
+ ### BREAKING CHANGES
11
+
12
+ * the deployed component map is `/etc/toa/.map.json.gz`.
13
+
14
+
6
15
  # [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
16
 
8
17
  * feat(core)!: let an operation state how long its calls are remembered ([af177c2](https://github.com/toa-io/toa/commit/af177c2ab3d00d475840b5ef9e612f04e82b72bd))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/boot",
3
- "version": "1.0.0-alpha.314",
3
+ "version": "1.0.0-alpha.315",
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.314",
25
- "@toa.io/core": "1.0.0-alpha.314",
26
- "@toa.io/definitions": "1.0.0-alpha.314",
24
+ "@toa.io/atomicity": "1.0.0-alpha.315",
25
+ "@toa.io/core": "1.0.0-alpha.315",
26
+ "@toa.io/definitions": "1.0.0-alpha.315",
27
27
  "@toa.io/generic": "1.0.0-alpha.311",
28
- "@toa.io/norm": "1.0.0-alpha.314",
28
+ "@toa.io/norm": "1.0.0-alpha.315",
29
29
  "@toa.io/schemas": "1.0.0-alpha.311",
30
30
  "clone-deep": "4.0.1",
31
- "dotenv": "17.4.2",
31
+ "dotenv": "18.0.0",
32
32
  "openspan": "1.0.0-alpha.305"
33
33
  },
34
- "gitHead": "4b7c0f4468e6fa89f95a69f43fed85c648fb033d"
34
+ "gitHead": "d88ed286bf44bf95b5f3d9db6e7d4621261dbb99"
35
35
  }
package/src/map.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import assert from 'node:assert'
2
+ import { gunzipSync } from 'node:zlib'
2
3
  import { readFile } from 'node:fs/promises'
3
4
  import * as core from '@toa.io/core'
4
5
 
@@ -78,6 +79,9 @@ export const contract = async (id) => {
78
79
  }
79
80
 
80
81
  /**
82
+ * A map is read gzipped where it is deployed and plain where it is not, so what it is is told by
83
+ * its first two bytes rather than by its name.
84
+ *
81
85
  * @param {string} path
82
86
  * @returns {Promise<Record<string, import('@toa.io/core').Contract>>}
83
87
  */
@@ -85,13 +89,19 @@ async function read(path) {
85
89
  let contents
86
90
 
87
91
  try {
88
- contents = await readFile(path, 'utf8')
92
+ contents = await readFile(path)
89
93
  } catch (cause) {
90
94
  throw new Error(`Cannot read the component map '${path}'`, { cause })
91
95
  }
92
96
 
93
97
  try {
94
- return JSON.parse(contents)
98
+ if (contents[0] === 0x1f && contents[1] === 0x8b) contents = gunzipSync(contents)
99
+ } catch (cause) {
100
+ throw new Error(`The component map '${path}' is not readable gzip`, { cause })
101
+ }
102
+
103
+ try {
104
+ return JSON.parse(contents.toString('utf8'))
95
105
  } catch (cause) {
96
106
  throw new Error(`The component map '${path}' is not JSON`, { cause })
97
107
  }
package/src/remote.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Remote, exceptions } from '@toa.io/core'
1
+ import { Remote, contract as coreContract, exceptions } from '@toa.io/core'
2
2
  import { remap } from '@toa.io/generic'
3
3
 
4
4
  import * as boot from './index.js'
@@ -11,13 +11,17 @@ import * as boot from './index.js'
11
11
  * tenant announced — and absent it, what the map this process was given states.
12
12
  */
13
13
  export const remote = async (locator, source, options = {}) => {
14
- const contract = options.contract ?? (await boot.map.contract(locator.id))
14
+ const stated = options.contract ?? (await boot.map.contract(locator.id))
15
15
 
16
- if (contract === undefined)
16
+ if (stated === undefined)
17
17
  throw new exceptions.UnstatedException(
18
18
  `Cannot call '${locator.id}': the component map states nothing of it. Run \`toa map\`.`
19
19
  )
20
20
 
21
+ // a contract states once, or not at all, what the runtime gives every component; the calls
22
+ // are made from the whole of it
23
+ const contract = coreContract.restore(stated)
24
+
21
25
  // a call binds its consumers, which are loaded rather than required
22
26
  const calls =
23
27
  contract.operations === undefined