@node-red/runtime
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -60,2 +60,4 @@ /** | ||
* @param {User} opts.user - the user calling the api | ||
* @param {Object} opts.flows - the flow configuration: `{flows: [..], credentials: {}}` | ||
* @param {Object} opts.deploymentType - the type of deployment - "full", "nodes", "flows", "reload" | ||
* @param {Object} opts.req - the request to log (optional) | ||
@@ -87,3 +89,3 @@ * @return {Promise<Flows>} - the active flow configuration | ||
} | ||
apiPromise = runtime.nodes.setFlows(flows.flows,deploymentType); | ||
apiPromise = runtime.nodes.setFlows(flows.flows,flows.credentials,deploymentType); | ||
} | ||
@@ -90,0 +92,0 @@ apiPromise.then(function(flowId) { |
@@ -248,3 +248,3 @@ /** | ||
if(typeof callback !== "function"){ | ||
throw new Error("Callback must be a function"); | ||
throw new Error("File Store cache disabled - only asynchronous access supported"); | ||
} | ||
@@ -308,3 +308,3 @@ var storagePath = getStoragePath(this.storageBaseDir ,scope); | ||
} else if (callback && typeof callback !== 'function') { | ||
throw new Error("Callback must be a function"); | ||
throw new Error("File Store cache disabled - only asynchronous access supported"); | ||
} else { | ||
@@ -311,0 +311,0 @@ self.writePromise = self.writePromise.then(function() { return loadFile(storagePath + ".json") }).then(function(data){ |
@@ -56,2 +56,3 @@ /** | ||
this.statusNodes = []; | ||
this.path = this.id; | ||
} | ||
@@ -124,3 +125,3 @@ | ||
start(diff) { | ||
this.trace("start "+this.TYPE); | ||
this.trace("start "+this.TYPE+" ["+this.path+"]"); | ||
var node; | ||
@@ -239,3 +240,3 @@ var newNode; | ||
node = this.activeNodes[id]; | ||
this.trace(" "+id.padEnd(16)+" | "+node.type.padEnd(12)+" | "+(node._alias||"")); | ||
this.trace(" "+id.padEnd(16)+" | "+node.type.padEnd(12)+" | "+(node._alias||"")+(node._zAlias?" [zAlias:"+node._zAlias+"]":"")); | ||
if (node.type === "catch") { | ||
@@ -242,0 +243,0 @@ this.catchNodes.push(node); |
@@ -109,3 +109,3 @@ /** | ||
} | ||
return setFlows(null,"load",false,forceStart); | ||
return setFlows(null,null,"load",false,forceStart); | ||
} | ||
@@ -115,6 +115,11 @@ | ||
* _config - new node array configuration | ||
* _credentials - new credentials configuration (optional) | ||
* type - full/nodes/flows/load (default full) | ||
* muteLog - don't emit the standard log messages (used for individual flow api) | ||
*/ | ||
function setFlows(_config,type,muteLog,forceStart) { | ||
function setFlows(_config,_credentials,type,muteLog,forceStart) { | ||
if (typeof _credentials === "string") { | ||
type = _credentials; | ||
_credentials = null; | ||
} | ||
type = type||"full"; | ||
@@ -160,12 +165,23 @@ if (settings.safeMode) { | ||
} | ||
var credsDirty; | ||
// Allow the credential store to remove anything no longer needed | ||
credentials.clean(config); | ||
if (_credentials) { | ||
// A full set of credentials have been provided. Use those instead | ||
configSavePromise = credentials.load(_credentials); | ||
credsDirty = true; | ||
} else { | ||
// Allow the credential store to remove anything no longer needed | ||
credentials.clean(config); | ||
// Remember whether credentials need saving or not | ||
var credsDirty = credentials.dirty(); | ||
// Remember whether credentials need saving or not | ||
var credsDirty = credentials.dirty(); | ||
configSavePromise = Promise.resolve(); | ||
} | ||
// Get the latest credentials and ask storage to save them (if needed) | ||
// as well as the new flow configuration. | ||
configSavePromise = credentials.export().then(function(creds) { | ||
configSavePromise = configSavePromise.then(function() { | ||
return credentials.export() | ||
}).then(function(creds) { | ||
var saveConfig = { | ||
@@ -521,3 +537,3 @@ flows: config, | ||
return setFlows(newConfig,'flows',true).then(function() { | ||
return setFlows(newConfig,null,'flows',true).then(function() { | ||
log.info(log._("nodes.flows.added-flow",{label:(flow.label?flow.label+" ":"")+"["+flow.id+"]"})); | ||
@@ -653,3 +669,3 @@ return flow.id; | ||
newConfig = newConfig.concat(nodes); | ||
return setFlows(newConfig,'flows',true).then(function() { | ||
return setFlows(newConfig,null,'flows',true).then(function() { | ||
log.info(log._("nodes.flows.updated-flow",{label:(label?label+" ":"")+"["+id+"]"})); | ||
@@ -676,3 +692,3 @@ }) | ||
return setFlows(newConfig,'flows',true).then(function() { | ||
return setFlows(newConfig,null,'flows',true).then(function() { | ||
log.info(log._("nodes.flows.removed-flow",{label:(flow.label?flow.label+" ":"")+"["+flow.id+"]"})); | ||
@@ -679,0 +695,0 @@ }); |
@@ -91,3 +91,3 @@ /** | ||
constructor(parent,globalFlow,subflowDef,subflowInstance) { | ||
// console.log("CREATE SUBFLOW",subflowDef.id,subflowInstance.id); | ||
// console.log("CREATE SUBFLOW",subflowDef.id,subflowInstance.id,"alias?",subflowInstance._alias); | ||
// console.log("SubflowInstance\n"+JSON.stringify(subflowInstance," ",2)); | ||
@@ -144,2 +144,3 @@ // console.log("SubflowDef\n"+JSON.stringify(subflowDef," ",2)); | ||
this.node_map = node_map; | ||
this.path = parent.path+"/"+(subflowInstance._alias||subflowInstance.id); | ||
@@ -456,3 +457,3 @@ var env = []; | ||
let nid = redUtil.generateId(); | ||
// console.log("Create Node In subflow",node.id, "--->",nid, "(",node.type,")") | ||
// console.log("Create Node In subflow",node._alias, "--->",nid, "(",node.type,")") | ||
// node_map[node.id] = node; | ||
@@ -459,0 +460,0 @@ node._alias = node.id; |
@@ -55,3 +55,3 @@ /** | ||
// Object.assign(this,config) | ||
// as part of its constructure - config._flow will overwrite this._flow | ||
// as part of its constructor - config._flow will overwrite this._flow | ||
// which we can tolerate as they are the same object. | ||
@@ -197,2 +197,3 @@ Object.defineProperty(this,'_flow', {value: n._flow, enumerable: false, writable: true }) | ||
var node = this; | ||
this.metric("receive", arg); | ||
if (node._inputCallback) { | ||
@@ -453,3 +454,2 @@ // Just one callback registered. | ||
} | ||
this.metric("receive",msg); | ||
this.emit("input",msg); | ||
@@ -468,2 +468,5 @@ }; | ||
} | ||
if (self._flow) { | ||
o.path = self._flow.path; | ||
} | ||
if (self.z) { | ||
@@ -470,0 +473,0 @@ o.z = self.z; |
@@ -28,6 +28,5 @@ /** | ||
function getFileMeta(root,path) { | ||
var fn = fspath.join(root,path); | ||
var fd = fs.openSync(fn,"r"); | ||
function getFileMeta(root, path) { | ||
var fn = fspath.join(root, path); | ||
var fd = fs.openSync(fn, 'r'); | ||
var size = fs.fstatSync(fd).size; | ||
@@ -37,17 +36,22 @@ var meta = {}; | ||
var length = 10; | ||
var remaining = ""; | ||
var remaining = Buffer.alloc(0); | ||
var buffer = Buffer.alloc(length); | ||
while(read < size) { | ||
read+=fs.readSync(fd,buffer,0,length); | ||
var data = remaining+buffer.toString(); | ||
var parts = data.split("\n"); | ||
remaining = parts.splice(-1); | ||
for (var i=0;i<parts.length;i+=1) { | ||
var match = /^\/\/ (\w+): (.*)/.exec(parts[i]); | ||
if (match) { | ||
meta[match[1]] = match[2]; | ||
} else { | ||
read = size; | ||
break; | ||
while (read < size) { | ||
read += fs.readSync(fd, buffer, 0, length); | ||
var data = Buffer.concat([remaining, buffer]); | ||
var index = data.lastIndexOf(0x0a); | ||
if (index !== -1) { | ||
var parts = data.slice(0, index).toString().split('\n'); | ||
for (var i = 0; i < parts.length; i++) { | ||
var match = /^\/\/ (\w+): (.*)/.exec(parts[i]); | ||
if (match) { | ||
meta[match[1]] = match[2]; | ||
} else { | ||
read = size; | ||
break; | ||
} | ||
} | ||
remaining = data.slice(index + 1); | ||
} else { | ||
remaining = data; | ||
} | ||
@@ -59,40 +63,17 @@ } | ||
function getFileBody(root,path) { | ||
var body = ""; | ||
var fn = fspath.join(root,path); | ||
var fd = fs.openSync(fn,"r"); | ||
var size = fs.fstatSync(fd).size; | ||
function getFileBody(root, path) { | ||
var body = ''; | ||
var fn = fspath.join(root, path); | ||
var data = fs.readFileSync(fn, 'utf8'); | ||
var parts = data.split('\n'); | ||
var scanning = true; | ||
var read = 0; | ||
var length = 50; | ||
var remaining = ""; | ||
var buffer = Buffer.alloc(length); | ||
while(read < size) { | ||
var thisRead = fs.readSync(fd,buffer,0,length); | ||
if (scanning) { | ||
var data = remaining+buffer.slice(0,thisRead).toString(); | ||
read += thisRead; | ||
var parts = data.split("\n"); | ||
if (read < size) { | ||
remaining = parts.splice(-1)[0]; | ||
} else { | ||
remaining = ""; | ||
} | ||
for (var i=0;i<parts.length;i+=1) { | ||
if (! /^\/\/ \w+: /.test(parts[i])) { | ||
scanning = false; | ||
body += (body.length > 0?"\n":"")+parts[i]; | ||
} | ||
} | ||
if (!scanning) { | ||
body += remaining; | ||
} | ||
} else { | ||
read += thisRead; | ||
body += buffer.slice(0,thisRead).toString(); | ||
for (var i = 0; i < parts.length; i++) { | ||
if (! /^\/\/ \w+: /.test(parts[i]) || !scanning) { | ||
body += (body.length > 0 ? '\n' : '') + parts[i]; | ||
scanning = false; | ||
} | ||
} | ||
fs.closeSync(fd); | ||
return body; | ||
} | ||
function getLibraryEntry(type,path) { | ||
@@ -99,0 +80,0 @@ var root = fspath.join(libDir,type); |
{ | ||
"name": "@node-red/runtime", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "Apache-2.0", | ||
@@ -19,4 +19,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@node-red/registry": "1.0.3", | ||
"@node-red/util": "1.0.3", | ||
"@node-red/registry": "1.0.4", | ||
"@node-red/util": "1.0.4", | ||
"clone": "2.1.2", | ||
@@ -23,0 +23,0 @@ "express": "4.17.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
480381
51
11509
+ Added@node-red/registry@1.0.4(transitive)
+ Added@node-red/util@1.0.4(transitive)
+ Addedjsonata@1.8.1(transitive)
+ Addeduglify-js@3.8.0(transitive)
- Removed@node-red/registry@1.0.3(transitive)
- Removed@node-red/util@1.0.3(transitive)
- Removedjsonata@1.7.0(transitive)
- Removeduglify-js@3.6.9(transitive)
Updated@node-red/registry@1.0.4
Updated@node-red/util@1.0.4