@toa.io/extensions.origins 0.20.0-dev.36 → 0.20.0-dev.38

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.36",
3
+ "version": "0.20.0-dev.38",
4
4
  "description": "Toa Origins",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -17,10 +17,10 @@
17
17
  "main": "transpiled/index.js",
18
18
  "types": "transpiled/index.d.ts",
19
19
  "dependencies": {
20
- "@toa.io/core": "0.20.0-dev.36",
21
- "@toa.io/generic": "0.20.0-dev.36",
22
- "@toa.io/pointer": "0.20.0-dev.36",
23
- "@toa.io/schemas": "0.20.0-dev.36",
20
+ "@toa.io/core": "0.20.0-dev.38",
21
+ "@toa.io/generic": "0.20.0-dev.38",
22
+ "@toa.io/pointer": "0.20.0-dev.38",
23
+ "@toa.io/schemas": "0.20.0-dev.38",
24
24
  "comq": "0.8.0",
25
25
  "msgpackr": "1.9.5",
26
26
  "node-fetch": "2.6.7"
@@ -36,5 +36,5 @@
36
36
  "preset": "ts-jest",
37
37
  "testEnvironment": "node"
38
38
  },
39
- "gitHead": "98bdecc65037fa5cfe588afde1161b63570fe8ab"
39
+ "gitHead": "12649c116b49db942e7caf1286c51625af3ad625"
40
40
  }
package/source/Factory.ts CHANGED
@@ -23,6 +23,7 @@ export class Factory implements extensions.Factory {
23
23
  return memo(async (): Promise<Configuration> => {
24
24
  const uris = await this.getURIs(locator, manifest)
25
25
  const allProperties = this.getProperties(locator)
26
+
26
27
  const origins = this.filterOrigins(uris, protocol.protocols)
27
28
  const properties = allProperties['.' + protocol.id as keyof Properties] ?? {}
28
29
 
@@ -36,7 +37,14 @@ export class Factory implements extensions.Factory {
36
37
  if (manifest === null) return map
37
38
 
38
39
  for (const [name, value] of Object.entries(manifest))
39
- map[name] = value !== null ? [value] : await this.readOrigin(locator, name)
40
+ try {
41
+ map[name] = await this.readOrigin(locator, name)
42
+ } catch {
43
+ // eslint-disable-next-line max-depth
44
+ if (value === null) throw new Error(`Origin value ${name} is not defined`)
45
+
46
+ map[name] = [value]
47
+ }
40
48
 
41
49
  return map
42
50
  }
@@ -32,14 +32,12 @@ function mergeDefaults (annotation: Annotation, instances: Instance[]): void {
32
32
  }
33
33
 
34
34
  function mergeInstance (origins: Origins, instance: Instance): Component {
35
- const id: string = instance.locator.id
36
-
37
35
  if (instance.manifest === null) return origins
38
36
 
39
37
  for (const [origin, value] of Object.entries(instance.manifest))
40
38
  if (origins[origin] === undefined)
41
39
  if (value === null)
42
- throw new Error(`Origin '${origin}' is not defined for '${id}'`)
40
+ throw new Error(`Origin '${origin}' is not defined for '${instance.locator.id}'`)
43
41
  else origins[origin] = value
44
42
 
45
43
  return origins