@toa.io/pointer 0.7.1 → 0.8.0-dev.0

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/pointer",
3
- "version": "0.7.1",
3
+ "version": "0.8.0-dev.0",
4
4
  "description": "Toa Pointer",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -24,9 +24,9 @@
24
24
  "main": "source/index.js",
25
25
  "dependencies": {
26
26
  "@toa.io/console": "0.6.0",
27
- "@toa.io/generic": "0.7.0",
28
- "@toa.io/schema": "0.7.1",
29
- "@toa.io/yaml": "0.7.1"
27
+ "@toa.io/generic": "0.8.0-dev.0",
28
+ "@toa.io/schemas": "0.8.0-dev.0",
29
+ "@toa.io/yaml": "0.7.2-dev.1"
30
30
  },
31
- "gitHead": "9989ea316ebf5698b1eee933e83a86e6a18b406b"
31
+ "gitHead": "5f1bfd167bb7919492d249f78bbcc6bd9fc645a4"
32
32
  }
@@ -1,8 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const { normalize, validate } = require('./.construct')
3
+ const { normalize } = require('./normalize')
4
+ const { validate } = require('./validate')
4
5
 
5
- /** @type {toa.pointer.uris.Constructor} */
6
+ /**
7
+ * @param {toa.pointer.URIs} declaration
8
+ * @returns {toa.pointer.URIs}
9
+ */
6
10
  const construct = (declaration) => {
7
11
  const normalized = normalize(declaration)
8
12
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  const { construct } = require('./construct')
4
4
  const { resolve } = require('./resolve')
5
+ const { validate } = require('./validate')
5
6
 
6
7
  exports.construct = construct
7
8
  exports.resolve = resolve
9
+ exports.validate = validate
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ /**
4
+ * @param {toa.pointer.URIs | string} declaration
5
+ * @returns {toa.pointer.URIs}
6
+ */
7
+ const normalize = (declaration) => {
8
+ if (typeof declaration === 'string') return { default: declaration }
9
+ return declaration
10
+ }
11
+
12
+ exports.normalize = normalize
@@ -1,5 +1,4 @@
1
1
  $schema: https://json-schema.org/draft/2019-09/schema
2
- $id: https://schemas.toa.io/0.0.0/storages/mongodb/annotations
3
2
 
4
3
  definitions:
5
4
  node:
@@ -2,14 +2,14 @@
2
2
 
3
3
  const path = require('path')
4
4
 
5
- const { Schema } = require('@toa.io/schema')
5
+ const schemas = require('@toa.io/schemas')
6
6
  const { load } = require('@toa.io/yaml')
7
7
 
8
- const schema = load.sync(path.resolve(__dirname, 'schema.yaml'))
9
- const validator = new Schema(schema)
8
+ const cos = load.sync(path.resolve(__dirname, 'schema.yaml'))
9
+ const schema = schemas.schema(cos)
10
10
 
11
11
  const validate = (declaration) => {
12
- const error = validator.fit(declaration)
12
+ const error = schema.fit(declaration)
13
13
 
14
14
  if (error) throw new TypeError(error.message)
15
15
  }
package/test/uris.test.js CHANGED
@@ -138,3 +138,7 @@ describe('resolve', () => {
138
138
  expect(url.href).toStrictEqual(uri)
139
139
  })
140
140
  })
141
+
142
+ it('should expose validate function', async () => {
143
+ expect(uris.validate).toBeInstanceOf(Function)
144
+ })
package/types/uris.d.ts CHANGED
@@ -8,8 +8,6 @@ declare namespace toa.pointer {
8
8
  [key: string]: Node
9
9
  }
10
10
 
11
- type Constructor = (declaration: URIs | string) => URIs
12
-
13
11
  type Resolution = {
14
12
  url: URL
15
13
  entry: string
@@ -27,6 +25,3 @@ declare namespace toa.pointer {
27
25
  }
28
26
 
29
27
  export type URIs = toa.pointer.URIs
30
-
31
- export const construct: toa.pointer.uris.Constructor
32
- export const resolve: toa.pointer.uris.Resolver
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { normalize } = require('./normalize')
4
- const { validate } = require('./validate')
5
-
6
- exports.normalize = normalize
7
- exports.validate = validate
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @param {toa.pointer.URIs | string} declaration
5
- * @returns {toa.pointer.URIs}
6
- */
7
- const normalize = (declaration) => {
8
- /** @type {toa.pointer.URIs} */
9
- let annotation
10
-
11
- if (typeof declaration === 'string') annotation = { default: declaration }
12
- else annotation = declaration
13
-
14
- return annotation
15
- }
16
-
17
- exports.normalize = normalize