@toa.io/boot 0.6.0 → 0.7.0-dev.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/boot",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-dev.1",
4
4
  "description": "Toa Boot",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -19,12 +19,12 @@
19
19
  "test": "echo \"Error: run tests from root\" && exit 1"
20
20
  },
21
21
  "dependencies": {
22
- "@toa.io/core": "0.6.0",
23
- "@toa.io/filesystem": "0.6.0",
24
- "@toa.io/generic": "0.6.0",
25
- "@toa.io/norm": "0.6.0",
26
- "@toa.io/schema": "0.6.0",
22
+ "@toa.io/core": "0.7.0-dev.1",
23
+ "@toa.io/filesystem": "0.7.0-dev.1",
24
+ "@toa.io/generic": "0.7.0-dev.1",
25
+ "@toa.io/norm": "0.7.0-dev.1",
26
+ "@toa.io/schema": "0.7.0-dev.1",
27
27
  "clone-deep": "4.0.1"
28
28
  },
29
- "gitHead": "a807d9906db194f5851613a1ead5450d277f4939"
29
+ "gitHead": "1ebdef6733499671422b624ee4e11ab4aa5dd21a"
30
30
  }
@@ -5,7 +5,7 @@ const { Composition } = require('@toa.io/core')
5
5
  const boot = require('./index')
6
6
 
7
7
  async function composition (paths, options) {
8
- options = Object.assign({}, options, EXTENSIONS)
8
+ options = Object.assign({}, options)
9
9
 
10
10
  /** @type {toa.norm.Component[]} */
11
11
  const manifests = await Promise.all(paths.map((path) => boot.manifest(path, options)))
@@ -29,8 +29,4 @@ async function composition (paths, options) {
29
29
  return new Composition(expositions.flat(), producers.flat(), receivers.flat(), tenants.flat())
30
30
  }
31
31
 
32
- const EXTENSIONS = {
33
- extensions: ['@toa.io/extensions.sampling']
34
- }
35
-
36
32
  exports.composition = composition
package/src/manifest.js CHANGED
@@ -1,12 +1,15 @@
1
1
  'use strict'
2
2
 
3
+ const { merge } = require('@toa.io/generic')
3
4
  const { component: load } = require('@toa.io/norm')
4
5
  const { Locator } = require('@toa.io/core')
5
6
 
6
7
  /**
7
8
  * @type {toa.boot.Manifest}
8
9
  */
9
- const manifest = async (path, options) => {
10
+ const manifest = async (path, options = {}) => {
11
+ merge(options, DEFAULTS)
12
+
10
13
  const manifest = await load(path)
11
14
 
12
15
  if (options?.bindings !== undefined) {
@@ -26,9 +29,19 @@ const manifest = async (path, options) => {
26
29
  }
27
30
  }
28
31
 
32
+ if (!('extensions' in manifest)) manifest.extensions = {}
33
+
34
+ for (const extension of options.extensions) {
35
+ if (!(extension in manifest.extensions)) manifest.extensions[extension] = null
36
+ }
37
+
29
38
  manifest.locator = new Locator(manifest.name, manifest.namespace)
30
39
 
31
40
  return manifest
32
41
  }
33
42
 
43
+ const DEFAULTS = {
44
+ extensions: ['@toa.io/extensions.sampling', '@toa.io/extensions.state']
45
+ }
46
+
34
47
  exports.manifest = manifest