@toa.io/bridges.node 1.0.0-alpha.59 → 1.0.0-alpha.63
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 +6 -6
- package/src/context.js +4 -14
- package/src/factory.js +1 -1
- package/src/shortcuts/index.js +2 -0
- package/src/shortcuts/logs.js +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/bridges.node",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.63",
|
|
4
4
|
"description": "Toa Node Bridge (inproc)",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"url": "https://github.com/toa-io/toa/issues"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">= 20.0.0"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/parser": "7.24.7",
|
|
30
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
31
|
-
"@toa.io/filesystem": "1.0.0-alpha.
|
|
32
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
30
|
+
"@toa.io/core": "1.0.0-alpha.63",
|
|
31
|
+
"@toa.io/filesystem": "1.0.0-alpha.63",
|
|
32
|
+
"@toa.io/generic": "1.0.0-alpha.63",
|
|
33
33
|
"fast-glob": "3.2.7",
|
|
34
34
|
"matchacho": "0.3.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"clone-deep": "4.0.1"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "9acf69d3135ea69bb9080c4f2f654d119f7b8a82"
|
|
40
40
|
}
|
package/src/context.js
CHANGED
|
@@ -5,29 +5,23 @@ const { underlay } = require('@toa.io/generic')
|
|
|
5
5
|
|
|
6
6
|
const shortcuts = require('./shortcuts')
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* @implements {toa.node.Context}
|
|
10
|
-
*/
|
|
11
8
|
class Context extends Connector {
|
|
9
|
+
operation
|
|
12
10
|
aspects
|
|
13
|
-
configuration
|
|
14
|
-
origins
|
|
15
11
|
|
|
16
12
|
#context
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
* @param {toa.core.Context} context
|
|
20
|
-
*/
|
|
21
|
-
constructor (context) {
|
|
14
|
+
constructor (context, operation) {
|
|
22
15
|
super()
|
|
23
16
|
|
|
17
|
+
this.operation = operation
|
|
24
18
|
this.#context = context
|
|
25
19
|
|
|
26
20
|
this.depends(context)
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
async open () {
|
|
30
|
-
this.aspects = this.#aspects(
|
|
24
|
+
this.aspects = this.#aspects(this.#context.aspects)
|
|
31
25
|
}
|
|
32
26
|
|
|
33
27
|
local = underlay(async ([endpoint], [request]) => {
|
|
@@ -42,10 +36,6 @@ class Context extends Connector {
|
|
|
42
36
|
return this.#context.call(namespace, name, endpoint, request)
|
|
43
37
|
})
|
|
44
38
|
|
|
45
|
-
/**
|
|
46
|
-
* @param {toa.core.extensions.Aspect[]} aspects
|
|
47
|
-
* @returns {{ [key: string]: Function}}
|
|
48
|
-
*/
|
|
49
39
|
#aspects (aspects) {
|
|
50
40
|
const map = {}
|
|
51
41
|
|
package/src/factory.js
CHANGED
|
@@ -10,7 +10,7 @@ const { extract } = require('./define/operations')
|
|
|
10
10
|
class Factory {
|
|
11
11
|
async algorithm (root, name, context) {
|
|
12
12
|
const module = load.operation(root, name)
|
|
13
|
-
const ctx = new Context(context)
|
|
13
|
+
const ctx = new Context(context, name)
|
|
14
14
|
|
|
15
15
|
return runner(module, ctx)
|
|
16
16
|
}
|
package/src/shortcuts/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const { state } = require('./state')
|
|
|
7
7
|
const { stash } = require('./stash')
|
|
8
8
|
const { storages } = require('./storages')
|
|
9
9
|
const { pubsub } = require('./pubsub')
|
|
10
|
+
const { logs } = require('./logs')
|
|
10
11
|
|
|
11
12
|
exports.http = http
|
|
12
13
|
exports.amqp = amqp
|
|
@@ -15,3 +16,4 @@ exports.state = state
|
|
|
15
16
|
exports.stash = stash
|
|
16
17
|
exports.storages = storages
|
|
17
18
|
exports.pubsub = pubsub
|
|
19
|
+
exports.logs = logs
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
function logs (context, aspect) {
|
|
4
|
+
function invoke (severity) {
|
|
5
|
+
return (message, attributes) => aspect.invoke(context.operation, severity, message, attributes)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
context.logs = CHANNELS.reduce((logs, channel) => {
|
|
9
|
+
logs[channel] = invoke(channel)
|
|
10
|
+
|
|
11
|
+
return logs
|
|
12
|
+
}, {})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CHANNELS = ['debug', 'info', 'warn', 'error']
|
|
16
|
+
|
|
17
|
+
exports.logs = logs
|