@toa.io/boot 1.0.0-alpha.7 → 1.0.0-alpha.8

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": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.8",
4
4
  "description": "Toa Boot",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -20,13 +20,13 @@
20
20
  "test": "echo \"Error: run tests from root\" && exit 1"
21
21
  },
22
22
  "dependencies": {
23
- "@toa.io/core": "1.0.0-alpha.7",
24
- "@toa.io/filesystem": "1.0.0-alpha.7",
25
- "@toa.io/generic": "1.0.0-alpha.7",
26
- "@toa.io/norm": "1.0.0-alpha.7",
27
- "@toa.io/schema": "1.0.0-alpha.7",
23
+ "@toa.io/core": "1.0.0-alpha.8",
24
+ "@toa.io/filesystem": "1.0.0-alpha.8",
25
+ "@toa.io/generic": "1.0.0-alpha.8",
26
+ "@toa.io/norm": "1.0.0-alpha.8",
27
+ "@toa.io/schema": "1.0.0-alpha.8",
28
28
  "clone-deep": "4.0.1",
29
29
  "dotenv": "16.1.1"
30
30
  },
31
- "gitHead": "4f5ac0bc342d4b7bd469fbe5c74266f050b55c9f"
31
+ "gitHead": "2ee18835c8214600e1d354251fa632913bff38c3"
32
32
  }
package/src/manifest.js CHANGED
@@ -14,28 +14,34 @@ const manifest = async (path, options = {}) => {
14
14
  const manifest = await load(path)
15
15
 
16
16
  if (options?.bindings !== undefined) {
17
- if ('operations' in manifest)
18
- for (const operation of Object.values(manifest.operations))
17
+ if ('operations' in manifest) {
18
+ for (const operation of Object.values(manifest.operations)) {
19
19
  operation.bindings = options.bindings
20
+ }
21
+ }
20
22
 
21
23
  const check = (binding) => require(binding).properties?.async === true
22
24
  const asyncBinding = options.bindings.find(check)
23
25
 
24
26
  if (asyncBinding === undefined) throw new Error('Bindings override must contain at least one async binding')
25
27
 
26
- if ('events' in manifest)
28
+ if ('events' in manifest) {
27
29
  for (const event of Object.values(manifest.events)) event.binding = asyncBinding
30
+ }
28
31
 
29
- if ('receivers' in manifest)
30
- for (const receiver of Object.values(manifest.receivers))
32
+ if ('receivers' in manifest) {
33
+ for (const receiver of Object.values(manifest.receivers)) {
31
34
  if (receiver.source === undefined) receiver.binding = asyncBinding
35
+ }
36
+ }
32
37
  }
33
38
 
34
39
  if (manifest.extensions === undefined) manifest.extensions = {}
35
40
 
36
- // add `null` manifests
37
- for (const extension of options.extensions) {
38
- if (!(extension in manifest.extensions)) manifest.extensions[extension] = null
41
+ if (options.extensions !== undefined) {
42
+ for (const extension of options.extensions) {
43
+ if (!(extension in manifest.extensions)) manifest.extensions[extension] = null
44
+ }
39
45
  }
40
46
 
41
47
  if ('storage' in options && 'entity' in manifest) manifest.entity.storage = options.storage
@@ -45,8 +51,6 @@ const manifest = async (path, options = {}) => {
45
51
  return manifest
46
52
  }
47
53
 
48
- const DEFAULTS = {
49
- extensions: ['@toa.io/extensions.sampling']
50
- }
54
+ const DEFAULTS = {}
51
55
 
52
56
  exports.manifest = manifest
package/src/storage.js CHANGED
@@ -6,11 +6,11 @@ const extensions = require('./extensions')
6
6
  const storage = (manifest) => {
7
7
  if (manifest.entity === undefined) return
8
8
 
9
- const [Factory, properties] = load(manifest)
9
+ const Factory = load(manifest)
10
10
 
11
11
  /** @type {toa.core.storages.Factory} */
12
12
  const factory = new Factory()
13
- const storage = factory.storage(manifest.locator, properties)
13
+ const storage = factory.storage(manifest.locator, manifest.entity)
14
14
 
15
15
  return extensions.storage(storage)
16
16
  }
@@ -20,22 +20,7 @@ function load (component) {
20
20
  const path = require.resolve(reference, { paths: [component.path, __dirname] })
21
21
  const { Factory } = require(path)
22
22
 
23
- const pkg = loadPackageJson(component.path, reference)
24
- const properties = pkg === null ? null : component.properties?.[pkg.name]
25
-
26
- return [Factory, properties]
27
- }
28
-
29
- function loadPackageJson (root, reference) {
30
- const packageJson = join(reference, 'package.json')
31
-
32
- try {
33
- const path = require.resolve(packageJson, { paths: [root, __dirname] })
34
-
35
- return require(path)
36
- } catch (e) {
37
- return null
38
- }
23
+ return Factory
39
24
  }
40
25
 
41
26
  exports.storage = storage