@toa.io/extensions.origins 0.20.0-dev.15 → 0.20.0-dev.17

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.origins",
3
- "version": "0.20.0-dev.15",
3
+ "version": "0.20.0-dev.17",
4
4
  "description": "Toa Origins",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -19,15 +19,15 @@
19
19
  "test": "echo \"Error: run tests from root\" && exit 1"
20
20
  },
21
21
  "dependencies": {
22
- "@toa.io/core": "0.20.0-dev.15",
23
- "@toa.io/generic": "0.20.0-dev.15",
24
- "@toa.io/schemas": "0.20.0-dev.15",
25
- "@toa.io/yaml": "0.20.0-dev.15",
22
+ "@toa.io/core": "0.20.0-dev.17",
23
+ "@toa.io/generic": "0.20.0-dev.17",
24
+ "@toa.io/schemas": "0.20.0-dev.17",
25
+ "@toa.io/yaml": "0.20.0-dev.17",
26
26
  "comq": "0.8.0",
27
27
  "node-fetch": "2.6.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node-fetch": "2.6.2"
31
31
  },
32
- "gitHead": "59b98b392985c2fb6ed8714e160f75a61c65d4b8"
32
+ "gitHead": "cafb719d8e80d3e78a00904dc6ab6d6b0d5b568b"
33
33
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  function check (reference) {
7
7
  if (typeof reference !== 'string') return // aspect properties object
8
+ if (!URL.canParse(reference)) return
8
9
 
9
10
  const url = new URL(reference)
10
11
 
@@ -62,16 +62,6 @@ describe('validation', () => {
62
62
 
63
63
  expect(() => deployment(components, annotations)).toThrow('must be object')
64
64
  })
65
-
66
- it('should throw if annotation is URI is not valid', async () => {
67
- const annotations = {
68
- [component.locator.id]: {
69
- [origin]: 'hello!'
70
- }
71
- }
72
-
73
- expect(() => deployment(components, annotations)).toThrow('must match format')
74
- })
75
65
  })
76
66
 
77
67
  it('should create variables', () => {
package/source/factory.js CHANGED
@@ -32,6 +32,8 @@ class Factory {
32
32
  continue
33
33
  }
34
34
 
35
+ if (!URL.canParse(reference)) throw new Error(`${reference} is invalid URL`)
36
+
35
37
  const url = new URL(reference)
36
38
 
37
39
  if (protocol.protocols.includes(url.protocol)) protocolManifest[origin] = reference
@@ -32,12 +32,6 @@ it('should pass if valid', async () => {
32
32
  expect(() => manifest(input)).not.toThrow()
33
33
  })
34
34
 
35
- it('should fail if not uri', async () => {
36
- const input = { [generate()]: generate() }
37
-
38
- expect(() => manifest(input)).toThrow('must match format')
39
- })
40
-
41
35
  it('should throw if protocol is not supported', async () => {
42
36
  const input = { foo: 'wat://' + generate() }
43
37
 
@@ -15,9 +15,13 @@ function deployment (instances) {
15
15
  const secrets = []
16
16
 
17
17
  for (const [origin, reference] of Object.entries(manifest)) {
18
- const url = new URL(reference)
18
+ let protocol
19
19
 
20
- if (protocols.includes(url.protocol)) {
20
+ const match = reference.match(RX)
21
+
22
+ if (match !== null) protocol = match.groups.protocol
23
+
24
+ if (protocols.includes(protocol)) {
21
25
  const originSecrets = createSecrets(locator, origin)
22
26
 
23
27
  secrets.push(...originSecrets)
@@ -60,4 +64,6 @@ function createSecret (locator, origin, property) {
60
64
  }
61
65
  }
62
66
 
67
+ const RX = /^(?<protocol>\w{1,12}:)/
68
+
63
69
  exports.deployment = deployment
@@ -1,2 +1,2 @@
1
1
  /^\./: <boolean>
2
- /^[a-zA-Z0-9]{1,32}$/: uri
2
+ /^[a-zA-Z0-9]{1,32}$/: string