@toa.io/extensions.configuration 1.1.0-dev.1 → 1.1.0-dev.10

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/extensions.configuration",
3
- "version": "1.1.0-dev.1",
3
+ "version": "1.1.0-dev.10",
4
4
  "description": "Toa Configuration",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -16,11 +16,11 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@toa.io/core": "1.1.0-dev.1",
20
- "@toa.io/generic": "0.11.0-dev.1",
21
- "@toa.io/schema": "0.7.6-dev.1",
22
- "@toa.io/yaml": "0.7.6-dev.1",
19
+ "@toa.io/core": "1.1.0-dev.10",
20
+ "@toa.io/generic": "0.11.0-dev.10",
21
+ "@toa.io/schema": "0.7.6-dev.10",
22
+ "@toa.io/yaml": "0.7.6-dev.10",
23
23
  "clone-deep": "4.0.1"
24
24
  },
25
- "gitHead": "ef65d2f42f13aac397c14f8c47eb026a191cda66"
25
+ "gitHead": "df6df35ff3e9f2d9416118a979d3885a8a1cd897"
26
26
  }
@@ -21,7 +21,6 @@ const convert = (node) => {
21
21
  }
22
22
 
23
23
  function property (node) {
24
- // if (node === null) throw new Error('Configuration: cannot resolve type of null, use JSONSchema declaration.')
25
24
  if (node === null) return { type: 'null', default: null }
26
25
 
27
26
  const type = Array.isArray(node) ? 'array' : typeof node
@@ -2,6 +2,7 @@ $schema: https://json-schema.org/draft/2019-09/schema
2
2
  $id: https://schemas.toa.io/0.0.0/extensions/configuration/manifest
3
3
 
4
4
  $ref: 'https://schemas.toa.io/0.0.0/definitions#/definitions/schema'
5
+ type: object
5
6
  properties:
6
7
  type:
7
8
  const: object
@@ -8,7 +8,7 @@ const { traverse } = require('@toa.io/generic')
8
8
  */
9
9
  const form = (schema) => {
10
10
  const defaults = (node) => {
11
- if (node.properties !== undefined) return { ...node.properties }
11
+ if (node.type === 'object' && node.properties !== undefined) return { ...node.properties }
12
12
  if (node.default !== undefined) return node.default
13
13
 
14
14
  return null
@@ -10,6 +10,7 @@ const instance = () => {
10
10
  const locator = new Locator(name, namespace)
11
11
 
12
12
  const manifest = {
13
+ type: 'object',
13
14
  properties: {
14
15
  foo: {
15
16
  type: 'number',
@@ -3,21 +3,20 @@
3
3
  const { generate } = require('randomstring')
4
4
 
5
5
  const schema = {
6
+ type: 'object',
6
7
  properties: {
7
8
  foo: {
8
9
  type: 'string',
9
10
  default: generate()
10
11
  },
11
12
  bar: {
13
+ type: 'object',
12
14
  properties: {
13
15
  baz: {
14
16
  type: 'number',
15
17
  default: 1
16
18
  }
17
19
  }
18
- },
19
- quu: {
20
- type: 'number'
21
20
  }
22
21
  }
23
22
  }
@@ -46,8 +46,7 @@ describe('defaults', () => {
46
46
  foo: fixtures.schema.properties.foo.default,
47
47
  bar: {
48
48
  baz: fixtures.schema.properties.bar.properties.baz.default
49
- },
50
- quu: 0
49
+ }
51
50
  })
52
51
  })
53
52
  })
package/source/factory.js CHANGED
@@ -11,11 +11,11 @@ const { Provider } = require('./provider')
11
11
  class Factory {
12
12
  /**
13
13
  * @param {toa.core.Locator} locator
14
- * @param {toa.schema.JSON | Object} declaration
14
+ * @param {toa.schema.JSON | Object} annotation
15
15
  * @return {toa.extensions.configuration.Aspect}
16
16
  */
17
- aspect (locator, declaration) {
18
- const schema = new Schema(declaration)
17
+ aspect (locator, annotation) {
18
+ const schema = new Schema(annotation)
19
19
  const provider = new Provider(locator, schema)
20
20
  const configuration = new Configuration(provider)
21
21
 
@@ -120,10 +120,4 @@ describe('normalization', () => {
120
120
 
121
121
  expect(() => manifest(concise)).toThrow(/array items type because it's empty/)
122
122
  })
123
-
124
- it('should throw on null', () => {
125
- const concise = { foo: null }
126
-
127
- expect(() => manifest(concise)).toThrow(/type of null/)
128
- })
129
123
  })