mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 15:34:26 +01:00
Merge branch 'master' into dev
This commit is contained in:
@@ -96,7 +96,11 @@ var api = module.exports = {
|
||||
} else if (scope === 'node') {
|
||||
var node = runtime.nodes.getNode(id);
|
||||
if (node) {
|
||||
ctx = node.context();
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
ctx = runtime.nodes.getContext(node.id);
|
||||
} else {
|
||||
ctx = node.context();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx) {
|
||||
@@ -104,13 +108,25 @@ var api = module.exports = {
|
||||
store = store || availableStores.default;
|
||||
ctx.get(key,store,function(err, v) {
|
||||
if (opts.keysOnly) {
|
||||
const result = {}
|
||||
if (Array.isArray(v)) {
|
||||
resolve({ [store]: { format: `array[${v.length}]`}})
|
||||
result.format = `array[${v.length}]`
|
||||
} else if (typeof v === 'object') {
|
||||
resolve({ [store]: { keys: Object.keys(v), format: 'Object' } })
|
||||
result.keys = Object.keys(v).map(k => {
|
||||
if (Array.isArray(v[k])) {
|
||||
return { key: k, format: `array[${v[k].length}]`, length: v[k].length }
|
||||
} else if (typeof v[k] === 'object') {
|
||||
return { key: k, format: 'object' }
|
||||
} else {
|
||||
return { key: k }
|
||||
}
|
||||
})
|
||||
result.format = 'object'
|
||||
} else {
|
||||
resolve({ [store]: { keys: [] }})
|
||||
result.keys = []
|
||||
}
|
||||
resolve({ [store]: result })
|
||||
return
|
||||
}
|
||||
var encoded = util.encodeObject({msg:v});
|
||||
if (store !== availableStores.default) {
|
||||
@@ -147,7 +163,7 @@ var api = module.exports = {
|
||||
}
|
||||
return
|
||||
}
|
||||
result[store] = { keys }
|
||||
result[store] = { keys: keys.map(key => { return { key }}) }
|
||||
c--;
|
||||
if (c === 0) {
|
||||
if (!errorReported) {
|
||||
@@ -225,7 +241,11 @@ var api = module.exports = {
|
||||
} else if (scope === 'node') {
|
||||
var node = runtime.nodes.getNode(id);
|
||||
if (node) {
|
||||
ctx = node.context();
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
ctx = runtime.nodes.getContext(node.id);
|
||||
} else {
|
||||
ctx = node.context();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx) {
|
||||
|
||||
@@ -719,6 +719,14 @@ class Flow {
|
||||
});
|
||||
}
|
||||
|
||||
getContext(scope) {
|
||||
if (scope === 'flow') {
|
||||
return this.context
|
||||
} else if (scope === 'global') {
|
||||
return context.get('global')
|
||||
}
|
||||
}
|
||||
|
||||
dump() {
|
||||
console.log("==================")
|
||||
console.log(this.TYPE, this.id);
|
||||
|
||||
@@ -49,6 +49,14 @@ class Group {
|
||||
}
|
||||
return this.parent.getSetting(key);
|
||||
}
|
||||
|
||||
error(msg) {
|
||||
this.parent.error(msg);
|
||||
}
|
||||
|
||||
getContext(scope) {
|
||||
return this.parent.getContext(scope);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -100,7 +100,24 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
||||
}
|
||||
} else if (type ==='jsonata') {
|
||||
pendingEvaluations.push(new Promise((resolve, _) => {
|
||||
redUtil.evaluateNodeProperty(value, 'jsonata', {_flow: flow}, null, (err, result) => {
|
||||
redUtil.evaluateNodeProperty(value, 'jsonata',{
|
||||
// Fake a node object to provide access to _flow and context
|
||||
_flow: flow,
|
||||
context: () => {
|
||||
return {
|
||||
flow: {
|
||||
get: (value, store, callback) => {
|
||||
return flow.getContext('flow').get(value, store, callback)
|
||||
}
|
||||
},
|
||||
global: {
|
||||
get: (value, store, callback) => {
|
||||
return flow.getContext('global').get(value, store, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null, (err, result) => {
|
||||
if (!err) {
|
||||
if (typeof result === 'object') {
|
||||
result = { value: result, __clone__: true}
|
||||
@@ -113,6 +130,10 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
||||
resolve()
|
||||
});
|
||||
}))
|
||||
} else if (type === "conf-type" && /^\${[^}]+}$/.test(value)) {
|
||||
// Get the config node from the parent subflow
|
||||
const name = value.substring(2, value.length - 1);
|
||||
value = flow.getSetting(name);
|
||||
} else {
|
||||
try {
|
||||
value = redUtil.evaluateNodeProperty(value, type, {_flow: flow}, null, null);
|
||||
|
||||
@@ -110,7 +110,8 @@ module.exports = {
|
||||
const payload = {
|
||||
session: sessionId,
|
||||
workspace: opts.data.workspace,
|
||||
node: opts.data.node
|
||||
node: opts.data.node,
|
||||
cursor: opts.data.cursor
|
||||
}
|
||||
runtime.events.emit('comms', {
|
||||
topic: 'multiplayer/location',
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"removing-modules": "Eliminando módulos de la configuración",
|
||||
"added-types": "Tipos de nodos añadidos:",
|
||||
"removed-types": "Tipos de nodos eliminados:",
|
||||
"removed-plugins": "Extensiones eliminadas:",
|
||||
"install": {
|
||||
"invalid": "Nombre de módulo no válido",
|
||||
"installing": "Instalando módulo: __name__, versión: __version__",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@node-red/util": "4.1.0-beta.0",
|
||||
"async-mutex": "0.5.0",
|
||||
"clone": "2.1.2",
|
||||
"express": "4.19.2",
|
||||
"express": "4.21.2",
|
||||
"fs-extra": "11.2.0",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"rfdc": "^1.3.1"
|
||||
|
||||
Reference in New Issue
Block a user