@toa.io/bridges.node 1.0.0-alpha.35 → 1.0.0-alpha.37

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/bridges.node",
3
- "version": "1.0.0-alpha.35",
3
+ "version": "1.0.0-alpha.37",
4
4
  "description": "Toa Node Bridge (inproc)",
5
5
  "homepage": "https://toa.io",
6
6
  "author": {
@@ -26,14 +26,14 @@
26
26
  "test": "echo \"Error: run tests from root\" && exit 1"
27
27
  },
28
28
  "dependencies": {
29
- "@toa.io/core": "1.0.0-alpha.35",
30
- "@toa.io/filesystem": "1.0.0-alpha.35",
31
- "@toa.io/generic": "1.0.0-alpha.35",
29
+ "@toa.io/core": "1.0.0-alpha.37",
30
+ "@toa.io/filesystem": "1.0.0-alpha.37",
31
+ "@toa.io/generic": "1.0.0-alpha.37",
32
32
  "fast-glob": "3.2.7",
33
33
  "matchacho": "0.3.5"
34
34
  },
35
35
  "devDependencies": {
36
36
  "clone-deep": "4.0.1"
37
37
  },
38
- "gitHead": "72963a7fdab122c0afe5d33928f4614d6c4f2455"
38
+ "gitHead": "e78a9aedb64a52dc34b9271fd90791934863d0a6"
39
39
  }
@@ -13,6 +13,8 @@ const define = (descriptor) => {
13
13
  definition.type = name
14
14
 
15
15
  if (node.params.length > 1) definition.scope = scope(node.params[1].name)
16
+ else definition.scope = 'none'
17
+
16
18
  if (node.params.length === 0) definition.input = null
17
19
 
18
20
  return definition
@@ -27,11 +29,15 @@ const test = (statement, type) => {
27
29
  return func && known
28
30
  }
29
31
 
30
- /**
31
- * @param {string} name
32
- * @returns {string}
33
- */
34
- const scope = (name) => scopes.includes(name) ? name : undefined
32
+ function scope (name) {
33
+ if (scopes.includes(name))
34
+ return name
35
+
36
+ if (name === 'context')
37
+ return 'none'
38
+
39
+ return undefined
40
+ }
35
41
 
36
42
  const nodes = ['FunctionDeclaration', 'ArrowFunctionExpression', 'ClassMethod']
37
43
 
@@ -67,7 +67,7 @@ describe('function', () => {
67
67
  const module = { computation }
68
68
  const definition = define(module)
69
69
 
70
- expect(definition).toMatchObject({ type: 'computation', scope: undefined })
70
+ expect(definition).toMatchObject({ type: 'computation', scope: 'none' })
71
71
  })
72
72
 
73
73
  it('should parse effect declaration', () => {
@@ -76,7 +76,7 @@ describe('function', () => {
76
76
  const module = { effect }
77
77
  const definition = define(module)
78
78
 
79
- expect(definition).toMatchObject({ type: 'effect', scope: undefined })
79
+ expect(definition).toMatchObject({ type: 'effect', scope: 'none' })
80
80
  })
81
81
 
82
82
  it('should parse expression', () => {
@@ -103,8 +103,8 @@ describe('function', () => {
103
103
  expect(definition.scope).toStrictEqual(undefined)
104
104
  })
105
105
 
106
- it('should not define scope', async () => {
107
- const observation = (input) => null
106
+ it('should not define unknown scope', async () => {
107
+ const observation = (input, message) => null
108
108
  const module = { observation }
109
109
  const definition = define(module)
110
110
 
@@ -168,7 +168,7 @@ describe('class', () => {
168
168
  expect(() => define(module)).toThrow('does not match conventions')
169
169
  })
170
170
 
171
- it('should define not define default scope', async () => {
171
+ it('should define none scope', async () => {
172
172
  class Observation {
173
173
  execute (input) {}
174
174
  }
@@ -176,7 +176,7 @@ describe('class', () => {
176
176
  const module = { Observation }
177
177
  const definition = define(module)
178
178
 
179
- expect(definition.scope).toBeUndefined()
179
+ expect(definition.scope).toBe('none')
180
180
  })
181
181
 
182
182
  it('should define null input', async () => {