@toa.io/norm 1.0.0-alpha.2 → 1.0.0-alpha.3

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/norm",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Toa declarations normalization and validation",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -20,11 +20,11 @@
20
20
  "test": "echo \"Error: run tests from root\" && exit 1"
21
21
  },
22
22
  "dependencies": {
23
- "@toa.io/core": "1.0.0-alpha.2",
24
- "@toa.io/generic": "1.0.0-alpha.2",
25
- "@toa.io/schema": "1.0.0-alpha.2",
26
- "@toa.io/schemas": "1.0.0-alpha.2",
27
- "@toa.io/yaml": "1.0.0-alpha.2"
23
+ "@toa.io/core": "1.0.0-alpha.3",
24
+ "@toa.io/generic": "1.0.0-alpha.3",
25
+ "@toa.io/schema": "1.0.0-alpha.3",
26
+ "@toa.io/schemas": "1.0.0-alpha.3",
27
+ "@toa.io/yaml": "1.0.0-alpha.3"
28
28
  },
29
- "gitHead": "7688e6e980a65c82ac2e459be4e355eebf406cd0"
29
+ "gitHead": "e36ac7871fc14d15863aaf8f9bbdeace8bdfa9f0"
30
30
  }
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const { hash } = require('@toa.io/generic')
4
+ const assert = require('node:assert')
4
5
 
5
6
  // these defaults are required before validation
6
7
  const defaults = (manifest) => {
@@ -19,7 +20,19 @@ const defaults = (manifest) => {
19
20
  if (manifest.prototype === undefined) manifest.prototype = '@toa.io/prototype'
20
21
 
21
22
  // TODO: bridge.version()
22
- if (manifest.version === undefined) manifest.version = '0.0.0'
23
+
24
+ if (manifest.version === undefined) {
25
+ const bridge = require(manifest.bridge)
26
+
27
+ if ('version' in bridge)
28
+ manifest.version = bridge.version(manifest)
29
+ }
30
+
31
+ if (manifest.version === undefined) {
32
+ console.warn(`Component '${manifest.namespace ? manifest.namespace + '.' : ''}${manifest.name}' has no version`)
33
+
34
+ manifest.version = Math.random().toString(36).slice(2)
35
+ }
23
36
  }
24
37
 
25
38
  function protoName (manifest) {
@@ -53,7 +53,7 @@ properties:
53
53
  - const: 'system'
54
54
 
55
55
  version:
56
- $ref: 'definitions#/definitions/version'
56
+ type: string
57
57
 
58
58
  build:
59
59
  type: object
@@ -4,7 +4,7 @@ $id: https://schemas.toa.io/0.0.0/context
4
4
  type: object
5
5
  properties:
6
6
  version:
7
- $ref: 'definitions#/definitions/version'
7
+ type: string
8
8
  name:
9
9
  $ref: 'definitions#/definitions/label'
10
10
  description:
@@ -20,7 +20,7 @@ properties:
20
20
  type: object
21
21
  properties:
22
22
  version:
23
- $ref: 'definitions#/definitions/version'
23
+ type: string
24
24
  registry:
25
25
  type: string
26
26
  format: uri
package/src/component.js CHANGED
@@ -13,7 +13,6 @@ const {
13
13
  collapse,
14
14
  dereference,
15
15
  defaults,
16
- dependencies,
17
16
  normalize,
18
17
  extensions
19
18
  } = require('./.component')
@@ -21,14 +21,6 @@ describe('runtime', () => {
21
21
  expect(() => validate(context)).toThrow(/required/)
22
22
  })
23
23
 
24
- it('should require version as semver', () => {
25
- delete context.runtime.version
26
- expect(() => validate(context)).toThrow(/required/)
27
-
28
- context.runtime.version = '.'
29
- expect(() => validate(context)).toThrow(/pattern/)
30
- })
31
-
32
24
  it('should require registry to match uri format', () => {
33
25
  context.runtime.registry = 'not-a-uri'
34
26
  expect(() => validate(context)).toThrow(/must match format/)