@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 +5 -5
- package/source/uris/construct.js +6 -2
- package/source/uris/index.js +2 -0
- package/source/uris/normalize.js +12 -0
- package/source/uris/{.construct/schema.yaml → schema.yaml} +0 -1
- package/source/uris/{.construct/validate.js → validate.js} +4 -4
- package/test/uris.test.js +4 -0
- package/types/uris.d.ts +0 -5
- package/source/uris/.construct/index.js +0 -7
- package/source/uris/.construct/normalize.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/pointer",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
28
|
-
"@toa.io/
|
|
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": "
|
|
31
|
+
"gitHead": "5f1bfd167bb7919492d249f78bbcc6bd9fc645a4"
|
|
32
32
|
}
|
package/source/uris/construct.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { normalize
|
|
3
|
+
const { normalize } = require('./normalize')
|
|
4
|
+
const { validate } = require('./validate')
|
|
4
5
|
|
|
5
|
-
/**
|
|
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
|
|
package/source/uris/index.js
CHANGED
|
@@ -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
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const schemas = require('@toa.io/schemas')
|
|
6
6
|
const { load } = require('@toa.io/yaml')
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
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 =
|
|
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
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,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
|